Button detached dialog select edit box text

Initialising edit box text with selected file, like so

    var srcTab = clickData.func.sourcetab;
    if (srcTab.stats.selitems > 0) {
        dialog.Control("edit1").value = srcTab.selected(0).name_stem;

Is there a way of automatically selecting edit box text when it is first displayed, if not is there a way of placing the cursor at the end of the edit box text.

I haven't checked with script dialogs, but giving the edit control focus (control.focus method) should normally also select its text.

        dialog.Control("edit1").value = source.selected(0).name_stem;
        dialog.Control("edit1").focus = true;

doesn't select the text;

Does the edit control already have focus when you change the text? That might stop it being selected (and would mean setting focus to the edit control was a no-op).

(This kinda of thing would be much easier if you post a small, self-contained example that we could try and modify ourselves.)

Here is the button (work in progress)
Iconset maker v2.dcf (7.7 KB)

the if statement at line 45 is where the edit text if present wants to be selected.


Here's a method that works, using SelectRange:

	if (source.stats.selitems > 0) {
		dialog.Control("edit1").value = source.selected(0).name_stem;

Works perfectly. Was only looking at properties in the documentation, should have looked further. Many thanks again.

1 Like

I missed it myself when I first looked.