Replace in Files / "Directory" field scrolls right when clicked
-
@Alan-Kilborn said in Replace in Files / "Directory" field scrolls right when clicked:
For me, it isn’t some random point, it’s that the entire text content of the Directory edit/combobox is selected.
Yes, you are correct. After the first click, the whole text is selected and scrolled to the right, and after the second click on the same position (i.e. without moving the mouse) the cursor is at a “random” position (“random” in the sense that it’s unpredictable for me in the beginning where I’ll get to after the second click).
-
@fml2 said in Replace in Files / "Directory" field scrolls right when clicked:
after the second click on the same position (i.e. without moving the mouse) the cursor is at a “random” position (“random” in the sense that it’s unpredictable for me in the beginning where I’ll get to after the second click).
For me, it is 100% deterministic / predictable: wherever my mouse was for the second click, that is where the caret will be after the select-all is cleared. (update: obviously, if I don’t wait for it to finish redrawing between the first and second click, then I can’t know where it will be; but if I click, wait a fraction of a second until I can see the character, then click again, it is 100% at that character when the select-all clears. If I do go too fast, it tends to double-click select a “word” rather than having a single caret.)
If that’s not sufficient for you, then do the first mouse click to select-all in the field, then, instead of clicking a second time, hit
HOME
to move the caret to the first character in the field, orEND
to move it to the last character in the field – again, 100% deterministic / predictable. -
@PeterJones said in Replace in Files / "Directory" field scrolls right when clicked:
If that’s not sufficient for you, then do the first mouse click to select-all in the field, then, instead of clicking a second time, hit HOME to move the caret to the first character in the field, or END to move it to the last character in the field – again, 100% deterministic / predictable.
Yeah, Ctrl+A followed by forward-arrow (to move to the end) or back-arrow (to move to the beginning) is just a really generically useful shortcut that works on all text buffers on Windows, not just in Notepad++.
-
@Alan-Kilborn said in Replace in Files / "Directory" field scrolls right when clicked:
All such controls in the Find family of windows works the same way: Clicking to put input focus in the control selects all text (and scrolls all the way to the right).
Other edit controls in Notepad++, e.g. the ones in the Column Editor input boxes, do not work the same way. Clicking in these puts the caret in the text at the point of the click, without selecting anything. If it is desired to select all text, a double-click will do that in these boxes.
I am nearly certain the difference is because the ones in Search dialogs are drop-down boxes (with a history) and not simple edit controls. Combo boxes behave that way normally in Windows. That can probably be changed by sub-classing the controls, though I’ve never attempted it. It’s usually a bad idea to alter the standard behavior of Windows controls unless you have a really good reason.
-
@Coises said :
It’s usually a bad idea to alter the standard behavior of Windows controls unless you have a really good reason.
This might be one of those times.
It’s one of those things that has nagged at me occasionally, but never enough where it was enough of a conscious awareness about what was happening to make me pursue it. -
@Alan-Kilborn said in Replace in Files / "Directory" field scrolls right when clicked:
@Coises said :
It’s usually a bad idea to alter the standard behavior of Windows controls unless you have a really good reason.
This might be one of those times.
It’s one of those things that has nagged at me occasionally, but never enough where it was enough of a conscious awareness about what was happening to make me pursue it.It has annoyed me too. But…
Consider that there is almost always something in those fields (either the last used value, or some text from the document in the “Find what” field). To type something entirely new, users would have to first type Ctrl+A — or, less sophisticated users might not know about that and believe they had to delete the existing text character by character or select it with the mouse first.
Changing this would be replacing an annoying behavior which users are used to with a different annoying behavior which users are not used to.
-
Actually, I’m not against marking the text. What I don’t like is the fact that the text is shown scrolled to the left but then is scrolled to the right when it gets focus. It’s like pulling the ground off under the feet.
I was not aware that this is the standard way text controls work in Windows.
-
@fml2 said in Replace in Files / "Directory" field scrolls right when clicked:
Actually, I’m not against marking the text. What I don’t like is the fact that the text is shown scrolled to the left but then is scrolled to the right when it gets focus. It’s like pulling the ground off under the feet.
I was not aware that this is the standard way text controls work in Windows.
It’s not standard for text controls. It’s standard for “drop-down” controls, where there is a downward-pointing arrow at the right side which you can click to get a list of choices, any of which you can then click to fill in the box.
It is allowed, but not common, to use this kind of control when the text is often too long to fit the width of the box.
Edit to add: I think the scrolling-to-the-right behavior is somehow implicit in the select-all behavior, but I wouldn’t want to say either way whether it would be possible to change it without causing other inconsistent behaviors.
-
@fml2 Seems to be the behavior of the CBS_AUTOHSCROLL style.
Constant Description CBS_AUTOHSCROLL Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is allowed. It’s like pulling the ground off under the feet.
At the moment you have some ground to stand on.
Removing this style means that the text width cannot exceed the edit control width. The ground may be pulled from under your feet entirely with removing this style as your long path would be too long in length.
I removed this style with Resource Hacker, tested the behavior and the result would disgust you. It is quite limiting of an experience.
-
@mpheath said in Replace in Files / "Directory" field scrolls right when clicked:
Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line.
Hrm… I don’t think this describes adequately what happens since the scrolling is done without me typing anything. The edit field just gets focus. I surely want to see the caret at all times if I’m actually typing something, i.e. the style you named is a good thing.
Is it possible to mark the text (I can see the benefit of marking the text on focus) but preserve the scrolling position? Is there a style responsible for that behaviour?
As of now it’s like you come to a store, see a price tag and want to buy the item. But in the moment you take it the price changes (I’ve actually experienced such thing on a hotel booking site). I.e. you don’t get what is advertised.
Upd: anyway, I see that it’s somehow a standard (or not unusual) behaviour, and, since it’s just a minor annoyance for me, I won’t pursue to change anything in the current way it works. Thank you all for your replies!
-
@Coises said in Replace in Files / "Directory" field scrolls right when clicked:
It’s not standard for text controls. It’s standard for “drop-down” controls, where there is a downward-pointing arrow at the right side which you can click to get a list of choices, any of which you can then click to fill in the box.
Interestingly, the behaviour of the “Find what” field in the same dialog (which is also a drop down list) is different: it’s shown scrolled to the right (both in “Find” and “Find in files” tab). This is OK IMO since the scrolling position is not changed when the field gets focus. Changing displayed part on focus is my main concern.
-
@fml2 said in Replace in Files / "Directory" field scrolls right when clicked:
Interestingly, the behaviour of the “Find what” field in the same dialog (which is also a drop down list) is different: it’s shown scrolled to the right (both in “Find” and “Find in files” tab). This is OK IMO since the scrolling position is not changed when the field gets focus. Changing displayed part on focus is my main concern.
I don’t see this. If both the “Find what” field and the “Directory” field are longer than will fit, when I open the dialog, the "Find what” field is highlighted and scrolled right, while the “Directory” field is scrolled left. If I then focus the “Directory” field (whether by clicking in it or by typing Alt+E), it is highlighted and scrolled right, while the “Find what” field loses highlighting and scrolls left.
It’s consistent for me: whenever a drop-down control receives focus, the entire control is highlighted (whether by mouse, keyboard or because it is the control that receives focus when the dialog is first opened), the insertion point is set to the far right, and if the text won’t fit in the control, the text is scrolled to the right. If focus is given by clicking, the position of the click is ignored.
Whenever focus leaves a drop-down control, highlighting is removed and if the text does not fit within the control, it is scrolled to the left.
-
@Coises said in Replace in Files / "Directory" field scrolls right when clicked:
the "Find what” field is highlighted and scrolled right, while the “Directory” field is scrolled left.
My point exactly. This is the difference. To me, it would be more logical if no scrolling took place upon focus. Why should the field be scrolled on focus? This disrupts the mental user context IMO.
-
@fml2 said in Replace in Files / "Directory" field scrolls right when clicked:
My point exactly. This is the difference. To me, it would be more logical if no scrolling took place upon focus. Why should the field be scrolled on focus? This disrupts the mental user context IMO.
There is no difference. You misunderstood what @Coises was trying to say: whichever combobox field you click in, that one highlights all the text and scrolls to the right; the other fields go back to their default state.
Follow this sequence:
- STATE = nothing active/selected/focused: both Find What and Directory show the beginning of the value (“scrolled left”)
- STATE = click in Find What: Find What text shows the end (“scrolled right”), no change to Directory
- STATE = click in Directory: Find What text deselects, and goes back to the beginning (“scrolled left”), and Directory selects all and shows the end (“scrolled right”)
- STATE = click back in Find What: it goes back to the exact same thing as state 2
They behave exactly the same: whichever one you click selects all and scrolls to the far right. There is no difference. This is standard Windows GUI behavior, and has been for at least two decades. This is not Notepad++ specific.
update: for example, in Microsoft
notepad.exe
, using the Save As dialog, where the File name field uses a combobox (typeable box with pulldown arrow on right for accessing other values):- STATE = nothing clicked/selected: the File name box is scrolled to the left, showing the beginning of the filename
- STATE = click in File name: it selects all and scrolls to the far right to show the end of the filename
This is the exact same behavior as in the Notepad++ dialog box. This is standard Windows GUI behavior.
- STATE = nothing active/selected/focused: both Find What and Directory show the beginning of the value (“scrolled left”)
-
@Coises , @PeterJones Now I see your point. So the “Find what” field is not scrolled to the right per se, but just because it happens to have focus when the dialog is opened. When I leave the field it gets scrolled back to the left (and the field receivinf focus is scrolled to the right).
I’ve tried several applications (including Editor and Excel) and found out that this last point (scrolling to the left when the field is left) is not done everywhere. Ofter, the text remains scrolled to the far right.
I don’t understand the logic begind it (when it’s done and when not), but I see that NP++'s behaviour does not differ (much) from that of other Windows applications.
Thank you for your patience.
Upd: Though it seems to be the standard behaviour with the drop dow lists, I still don’t get the rationale behind it. Why should something be shown one way when it doesn’t have focus and the other way when it does?