Is it possible to turn off automatic selection in the Replace dialog?
-
Hello!
Is it possible to turn off automatic selection and focus of the Find what textbox when N++/Replace dialog gets the focus again?
My use case: I fill Find what and go to Replace with. I use Ditto clipboard manager to access an earlier clipboard text. After Ditto closes, N++/Replace dialog gets the focus again, jumps to Find what, selects all text, then the paste operation puts the text intended to the Replace with textbox to the Find what textbox.
It’s most destructive when the text is longer than the textbox and the difference is not visible.
To jump and select Find what is perfect when I press Ctrl+H, but not on re-focused dialog window.
-
I don’t have the Ditto clipboard manager, but if I do
Ctrl+H
, and enter FIND=one
and REPLACE=two
, thenAlt+Tab
into web browser, copy text from there, andAlt+Tab
back to Notepad++, it does change focus back to FIND entry, but it doesn’t change the text in there to the contents of my clipboard. I don’t think it’s Notepad++ itself that’s populating the new version of the FIND, because without the Ditto clipboard manager, I cannot replicate your symptoms.Thus, my guess is that your Ditto clipboard manager is actually sending a PASTE command to the last application that had focus, rather than just putting an old clipboard entry into the active clipboard so that you can manually paste it. As a test that might confirm my hypothesis: instead of having Notepad++ open to the FIND/REPLACE dialog, just have it open to an empty file that’s typable; then use Ditto in the same manner, and
Alt+Tab
back to Notepad++ – if it has pasted the text that you chose from Ditto, then it’s Ditto that’s sending the text rather than Notepad++, and you will want to look into Ditto settings to see if it can just populate the main clipboard from your actions rather than sending the PASTE action to another application. -
@PeterAdam said in Is it possible to turn off automatic selection in the Replace dialog?:
My use case: I fill Find what and go to Replace with. I use Ditto clipboard manager to access an earlier clipboard text. After Ditto closes, N++/Replace dialog gets the focus again, jumps to Find what, selects all text, then the paste operation puts the text intended to the Replace with textbox to the Find what textbox.
I have a similar problem with the clipboard manager I use (Outertech Clipboard History, which appears to be gone now). When I press the Caps Lock key it displays a menu from which I can select any of the last 15 things I copied to the clipboard, or any of a number of entries I’ve made sticky; it then pastes the selection at the cursor location. This works almost everywhere except in the Notepad++ Search dialogs: in those, the Find field is replaced no matter what field the cursor was in.
I assumed it was such an unusual case that no one would care to address it. That might or might not be true, but at least I can confirm that it happens.
It does appear that whenever the dialog regains focus, it selects the entire Find field. This even happens if all you do is put focus in the document and then switch back to the dialog by clicking on the title bar. I know of no way to stop it.
-
This behavior may be by accident. At the end of processing for the WM_ACTIVATE message, the dialog procedure returns TRUE.
According to Microsoft documentation, an application which processes WM_ACTIVATE should return zero (FALSE).
I just tested in MSVS, and when I change that from TRUE to FALSE, the cursor stays in the same field when using my clipboard manager or otherwise changing focus.
However, it still selects the entire field, so there might be something else going on as well.I still can’t paste from the clipboard manager without replacing the entire field… but at least it’s the expected field.Long shot, but does anyone know if this behavior (always returning focus to the Find field) is intended or accidental?
Edit to add: After a bit of investigation, I see that unlike an ordinary edit box, changing focus to a combo box anywhere in Windows normally selects the entire content. So that part isn’t strange. The choose-and-paste function of my clipboard monitor replaces the entire previous content in combo boxes in any application. (@PeterAdam can tell us if his does the same. The File name field of a system Open or Save As dialog is a good test.)
-
I use Ditto, but not in a way that I couldn’t live without it. :-)
It works a bit differently than other clipboard managers I’ve used in the past.
Double-clicking a historical clipboard entry in the Ditto UI seems to do two things instead of one: It copies the double-clicked entry’s text to the clipboard (very expected) but it also activates the app that was active previously and performs a paste (I found this unexpected when I first started using Ditto).
OK, enough about Ditto before getting called out for being off-topic. :-)So, yes, I can replicate OP’s original problem, I think. Here’s what I tried:
- deactivate N++ (by double-clicking an entry in the Ditto UI) with N++ input focus in the Replace with box (text there can either be selected or not)
- due to the double-click in Ditto, N++ and its Replace window is reactivated, but the text of the Ditto entry chosen is now in Find what, not the intended Replace with
Reading again now the OP’s original posting, I haven’t added anything new, but just shown that I can replicate the problem using N++ 8.7 and Ditto.
-
@Coises said :
does anyone know if this behavior (always returning focus to the Find field) is intended or accidental?
I’ll hazard a guess and say “accidental”, i.e., bug.
It probably hasn’t been noticed before because a more typical action sequence might be:
- user working with input focus in Replace with decides he needs his replacement data from another app source
- user activates other app, copies needed data to clipboard
- user reactivates N++ by clicking in the Replace window in the Replace with box (that’s where he’s going to be pasting, after all)
With this sequence there is no problem (with possible exception that the text of Replace with is now fully selected, when maybe it wasn’t when he left).
However, if user tries to do the above sequence with keyboard actions and not mouse (e.g. Alt+tab to switch apps, …), then with return to N++ the user’s input focus is now in the Find what box and NOT the Replace with box. So…it seems, same problem via different route.
-
@Coises said in Is it possible to turn off automatic selection in the Replace dialog?:
Long shot, but does anyone know if this behavior (always returning focus to the Find field) is intended or accidental?
IMO - it is an annoying bug and has to be fixed.
@Coises said in Is it possible to turn off automatic selection in the Replace dialog?:
I just tested in MSVS, and when I change that from TRUE to FALSE, the cursor stays in the same field when using my clipboard manager or otherwise changing focus.
I did a quick test - that fix works ok for me too.
If you have a time for it, please create an issue & PR for it, thanks. -
@xomx said in Is it possible to turn off automatic selection in the Replace dialog?:
If you have a time for it, please create an issue & PR for it, thanks.
I see there is already an issue, #6021. I’ve added a comment and a pull request.
-
@PeterJones “look into Ditto settings to see if it can just populate the main clipboard from your actions rather than sending the PASTE action to another application.”
Yes, it can be set that way but it is a productivity tool, why press ctrl+v after I have already decided what to paste in Ditto?
@Coises “changing focus to a combo box anywhere in Windows normally selects the entire content. So that part isn’t strange.” - it is expected and desired, but I am already in the Replace with textbox, not in the Find what one.
Also, you may try Win+V in Windows 10+, but it’s history is deleted on shutdown; and it does not place the last used item to the top of the list (quite annoying during mass replacing many text to a single one, the single one sunks in the list, so sometimes after a time, it is easier to type it again).
It uses a different mechanism, so it works with N++ even now.Thanks for creating an issue and a fix!