Focusing on the open document
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,
mariusv-github last edited by
I am not sure in you case, but you can try 2 different solutions:
- Using the NPPM_SWITCHTOFILE NPP message with the filePahName of you opened document (https://npp-user-manual.org/docs/plugin-communication/#nppm-switchtofile).
- 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.
@mariusv-github Hi, the first solution worked. Thank you very much!
dail last edited by
@dail Nice. Thanks!