Community
    • Login

    Focusing on the open document

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    5 Posts 3 Posters 579 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.
    • dipaolovD
      dipaolov
      last edited by

      Hi all,

      I’m developing a plugin to help me with my HDL/FPGA development process.

      For now, it just compiles the open file with the Modelsim compiler and displays the output lines in the list box of a docking dialog placed in the bottom of Notepad++: double-clicking on an item of the list box moves the cursor to the line of the open document that caused the error.

      For the double-clicking action, I based my code on the FunctionList code of the last version of Notepad++. The problem is, I can’t understand how to focus on the open document after I move the cursor to the right line.

      In Notepad++ (file PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp, line 582), it’s just:

      PostMessage(_hParent, WM_COMMAND, SCEN_SETFOCUS << 16, reinterpret_cast<LPARAM>((*_ppEditView)->getHSelf()));
      

      My question is: how can I do the same thing from within my plugin?

      Thank you very much,
      Vince.

      1 Reply Last reply Reply Quote 1
      • mariusv-githubM
        mariusv-github
        last edited by

        Hi dipaolov,
        I am not sure in you case, but you can try 2 different solutions:

        1. Using the NPPM_SWITCHTOFILE NPP message with the filePahName of you opened document (https://npp-user-manual.org/docs/plugin-communication/#nppm-switchtofile).
        2. Using SetFocus Windows API (if you document is already at the foreground level) with the handle of the right Scintilla instance: Main/Second from NppData (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setfocus). This second solution maybe needs to call AttachThreadInput from your plugin before SetFocus because maybe your plugin executes in a different thread than the Scintilla thread.
        dipaolovD 1 Reply Last reply Reply Quote 3
        • dipaolovD
          dipaolov @mariusv-github
          last edited by

          @mariusv-github Hi, the first solution worked. Thank you very much!

          Vince.

          1 Reply Last reply Reply Quote 2
          • dailD
            dail
            last edited by

            @dipaolov Another solution might be SCI_GRABFOCUS

            dipaolovD 1 Reply Last reply Reply Quote 1
            • dipaolovD
              dipaolov @dail
              last edited by

              @dail Nice. Thanks!

              V.

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