Focusing on the open document
-
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. -
Hi dipaolov,
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!
Vince.
-
@dipaolov Another solution might be
SCI_GRABFOCUS -
@dail Nice. Thanks!
V.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login