Community
    • Login

    NppMenuSearch version 0.9.7 available

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    13 Posts 3 Posters 367 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • peter-frentrupP
      peter-frentrup @Vitalii Dovgan
      last edited by

      @Vitalii-Dovgan Thanks for reporting. I implemented a quick fix (using the already existing event ToolbarSearchForm.AfterCompleteInit) and updated the release binaries.
      I did not change the version number, because I think that the issue can only occur if one bypasses the windows event loop and calls the internal function Main.MenuSearchFunction() directly instead of via the registered command.

      Vitalii DovganV 1 Reply Last reply Reply Quote 4
      • Vitalii DovganV
        Vitalii Dovgan @peter-frentrup
        last edited by

        @peter-frentrup
        Thank you, now it works via the loader.
        Though, the C++ loader adds a strange new “feature” now: when the “Menu Search” function is called for the very first time, at first, when the “NppMenuSearch.dll” is loaded by the C++ loader, the search text box gets the focus as expected. However, then, when the MenuSearchFunction is actually called for the first time, the focus unexpectedly returns back to Scintilla. As far as I understand, this is somehow connected to the fact that SelectSearchField exits at that moment, posponing the execution of afterCompleteInit_SelectSearchField. Then, when the latter is being executed, I do see that

        txtSearch.SelectAll();
        txtSearch.Focus();
        txtSearch_TextChanged(null, null);
        

        are called, however the focus does not return to the search text box.
        Sorry for bothering you with these details related to the C++ loader, I just thought maybe you could give me a hint what to do here?

        peter-frentrupP 1 Reply Last reply Reply Quote 0
        • peter-frentrupP
          peter-frentrup @Vitalii Dovgan
          last edited by

          @Vitalii-Dovgan In Main.PluginReady(), I explicitly send SCI_GRABFOCUS to explicitly set focus to the current Scintilla editor for some reason (probably the toolbar was otherwise stealing focus… I am not sure about the exact circumstances, that code is old):

          internal static void PluginReady()
          {
            ...
            ToolbarSearchForm.CheckToolbarVisiblity();
            Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GRABFOCUS, 0, 0);
            ...
          }
          

          Maybe this interferes with your code?

          Vitalii DovganV 1 Reply Last reply Reply Quote 0
          • Vitalii DovganV
            Vitalii Dovgan @peter-frentrup
            last edited by

            @peter-frentrup

            Hmm, looks close, but does not seem to be.
            If I comment out the line with the SciMsg.SCI_GRABFOCUS, nothing changes.
            So far, whatever I tried, the focus is stolen to Scintilla. I stopped to trust myself, so I reverted the “NppMenuSearch.dll” to its previous version 0.9.6. With the 0.9.6, the focus remains in the search text box.

            Here is the C++ wrapper available in Git in case you or someone else would like to play with it:
            https://github.com/d0vgan/npp-plugins-CppWrappers/tree/master/NppMenuSearchCpp

            1 Reply Last reply Reply Quote 0
            • astewart77A
              astewart77 @peter-frentrup
              last edited by

              @peter-frentrup Is it possible to show all Recently Used items, not just ones matching a search string? For those days when I forgot what I just did…

              peter-frentrupP 1 Reply Last reply Reply Quote 0
              • peter-frentrupP
                peter-frentrup @astewart77
                last edited by

                @astewart77 No, that is not possible with the plugin.

                @Vitalii-Dovgan Another possiblity is the dummy dialog procedure I use when loading each page:

                public static class DialogHelper {
                ...
                public static IntPtr LoadNppDialog(IntPtr hwndParent, int dialogResoucreId)
                {
                    ...
                    return CreateDialogParam(exeModule, (IntPtr)dialogResoucreId, hwndParent, DialogProcedureDelegate, IntPtr.Zero);
                }
                
                static IntPtr DialogProcedure(IntPtr hwndDlg, uint uMsg, IntPtr wParam, IntPtr lParam)
                {
                    switch (uMsg)
                    {
                        case (uint)Win32.WM_INITDIALOG:
                            return (IntPtr)1;
                
                        default:
                            return IntPtr.Zero;
                    }
                }
                ...
                }
                

                Returning 1 for WM_INITDIALOG actually means direct the system to set the keyboard focus to the first possible control. Maybe 0 would be better here.

                Vitalii DovganV 1 Reply Last reply Reply Quote 1
                • Vitalii DovganV
                  Vitalii Dovgan @peter-frentrup
                  last edited by

                  @peter-frentrup said in NppMenuSearch version 0.9.7 available:

                  DialogProcedure

                  You are right!!! The usage of return IntPtr.Zero for WM_INITDIALOG did the trick!

                  1 Reply Last reply Reply Quote 0
                  • Vitalii DovganV
                    Vitalii Dovgan
                    last edited by

                    Here is a strange-looking double-lined item in the list, this is while searching for “delim”:

                    4d91c6d3-a94c-4242-bb17-38e49183ae82-image.png

                    Here is the corresponding item in Preferences - Delimiter:

                    bd7937db-602b-45b0-a0fd-5390b5a8ef8f-image.png

                    I think, we may just truncate such items to their first line.

                    1 Reply Last reply Reply Quote 0
                    • Vitalii DovganV
                      Vitalii Dovgan
                      last edited by

                      By the way, what is the reasoning behind clearing the Search text when Enter is pressed and not clearing it when Esc is pressed?
                      Since the Search text becomes fully selected when the “Menu Search” function is called, I’d rather expect to have the Search text preserved after Enter is pressed. Who knows, maybe I’ll want to do the very same search again?

                      peter-frentrupP 1 Reply Last reply Reply Quote 0
                      • peter-frentrupP
                        peter-frentrup @Vitalii Dovgan
                        last edited by

                        @Vitalii-Dovgan It annoys me like hell when the search term lingers around after I found what I want. I find it “cleaner” to return to the default state that reminds me of the shortcut.
                        Regarding the ESC behaviour: maybe I should clear the field in that case too 🤔

                        About the visual glitch: I will slam everything into a single line.

                        So the dialog procedure could simplify 👍

                        There was also a problem when one attempts to navigate to a hidden preference item that has the same ID as some other control on a different page. E.g. the second line “bla bla ba bla …” on the “Delimiter” page. It seems that another update is due 🙄

                        Vitalii DovganV 1 Reply Last reply Reply Quote 2
                        • Vitalii DovganV
                          Vitalii Dovgan @peter-frentrup
                          last edited by Vitalii Dovgan

                          Here is a funny scenario:

                          1. type “menu” in the Search textbox;
                          2. select Plugins -> NppMenuSearch -> Menu Search…
                          3. press Enter.
                            As the result, the Search textbox does not have a focus!

                          Well, I know this is a strange use-case: call itself, but anyway :)

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors