• Login
Community
  • Login

Focusing on the open document

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
5 Posts 3 Posters 580 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.
  • D
    dipaolov
    last edited by Dec 4, 2022, 7:25 AM

    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
    • M
      mariusv-github
      last edited by Dec 4, 2022, 8:10 AM

      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.
      D 1 Reply Last reply Dec 5, 2022, 5:04 PM Reply Quote 3
      • D
        dipaolov @mariusv-github
        last edited by Dec 5, 2022, 5:04 PM

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

        Vince.

        1 Reply Last reply Reply Quote 2
        • D
          dail
          last edited by Dec 6, 2022, 12:33 PM

          @dipaolov Another solution might be SCI_GRABFOCUS

          D 1 Reply Last reply Dec 6, 2022, 3:55 PM Reply Quote 1
          • D
            dipaolov @dail
            last edited by Dec 6, 2022, 3:55 PM

            @dail Nice. Thanks!

            V.

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