Select existing text when click the search bar

Hello. Is there a way to make existing text to be selected (and so ready to be replaced) when we click the search bar in TW?

I find it a little inconvenient to have to delete existing text in the search bar first before I search for a new thing.

The $edit-text widget focus="yes"parameter automatically puts the focus into the input control when it is first created, and selects the contents when the input control gets focus.

However, this only works if you use the keyboard to move the focus into the input control… if you click, then the cursor position in the input control is determined by where you click.

For most use-cases, this is what you’d expect to happen. Even so, it would be nice if there was an option to select the entire input control contents even it gets focus as a result of a click action. Perhaps a new parameter could be added, e.g. focusSelect="yes", which would select the contents when the field gets the focus even as a result of a click action.

Unfortunately, because the $edit-text widget handles many different use-cases, the TWCore code is really complex, and it’s not obvious to me where this new parameter would be handled.

I suggest opening a ticket on GitHub, and see what Jeremy has to say about it.

-e

@Pak

Listening carefully to what you said – specifically “when we click the search bar in TW

why don’t you double-click and then just start typing?

If you have several space-separated words in the search input control, double clicking will select only the word under the mouse (or the last word if you to the right of the text). However… triple clicking selects the entire input control contents. I’m not sure if this is a general cross-platform convention, or if it’s only a Windows thing.

-e

1 Like

Thanks Eric

Best I could find was this answer on SO:

Ahhh. Does this include keyboard shortcut? I tried ctrl+shift+F (default for sidbar search) but it does not seem to select the current search text.

Tripple-clicking the textbox does indeed select all texts (with spaces). But it’s quite a lot of clicking especially if you search very often.

What I did is I hit Esc first to clear the search text then start typing. But it’s one extra click. For back-to-back searching, having the ability to click on the search bar and start typing away would be very nice.

Ctrl+Shift+F, Ctrl+A ?

Triple click is a lot easier.

Agreed.

Not sure if it fits your workflow, but a slightly different approach would be to modify the code such that when you click a link from the search drop-down it also clears the input box at that point. That way the input box is essentially always empty when you need to use it again?

1 Like

I learn something new everyday, often because of Eric :grinning:

1 Like