NppPythonScripts icon indicating copy to clipboard operation
NppPythonScripts copied to clipboard

Can WinDialog be extended to create Notepad++ dockable dialogue?

Open vinsworldcom opened this issue 2 years ago • 5 comments

Obviously cannot from ctypes import NotepadPlusPlus.DockingDlgInterface, but wondering if you can create the tTbData structure:

https://github.com/npp-plugins/plugintemplate/blob/fd051e4cadaa2adcbedfdc27a817bc72eb0ae174/src/DockingFeature/Docking.h#L49-L63

and then register it:

SendMessage(notepad.hwnd, NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);

If you could pull it off? That would be a huge win allowing PythonScript to essentially be a full-fledged Notepad++ plugin creator scripting language.

Cheers.

vinsworldcom avatar Dec 20 '23 02:12 vinsworldcom

Hi, in general, yes, but I have an issue whose cause I have not yet found. Another problem(?) is how such a dialog would be handled after a restart of Npp. I hope to find some time over the Christmas holidays to look into this in more detail.

Ekopalypse avatar Dec 20 '23 11:12 Ekopalypse

I see. I was going to play around with it, but it seems your 'WinDialog_tests_\test_npp_downloader.py' script is different than the one I have in my clone of the repo.

Cheers.

vinsworldcom avatar Dec 20 '23 12:12 vinsworldcom

Ah, yes - the dockable dialog feature hasn't been made public yet. I'll publish another branch with this experiment after work (3-4h) today.

Ekopalypse avatar Dec 20 '23 12:12 Ekopalypse

See https://github.com/Ekopalypse/NppPythonScripts/tree/dockable_dialog_experiment

from Npp import console

from WinDialog import DockableDialog, Button

class MyDialog(DockableDialog):
    def __init__(self, title='Dockable Dialog Test'):
        super().__init__(title=title)

        self.pointsize = 11
        self.typeface = 'Segoe UI'

        self.btn1 = Button('Button1', (40, 11), (0, 0))
        self.btn2 = Button('Button2', (40, 11), (40, 0))

        self.btn1.onClick = self.on_click1
        self.btn2.onClick = self.on_click2
        

    def on_click1(self):
        print("button 1 pressed")

    def on_click2(self):
        print("button 2 pressed")



console.show()
dlg = MyDialog()
dlg.show()

Just to be clear: I haven't really tested it, but I haven't had any major problems with it.

Ekopalypse avatar Dec 20 '23 16:12 Ekopalypse

With Rust and CreateDialogIndirectParamW it works, so it looks like it's not a problem with this API function ... hmm ...

rust_dynamic_dlg

Ekopalypse avatar Dec 27 '23 09:12 Ekopalypse