- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Default button selection/highlight in modal window
Is it possible to set specific button as selected button in modal window to allow usage of that button with enter/space press?
In the example script I have added I would like to have default selection to be "OK" button of modal window but by default it is set as first selection of radio box (in this case "Option 1") and I haven't figured out how to change it. I managed to do this by creating fake button as first element in the new window (selected by default) which clicks the Ok button but I feel this is a bit hacky way to get it working (commented out in the example script).
Names Default To Here(1);
okPushed = 0;
nw = New Window("Modal window", << modal, Show toolbars(0), Show menu(0),
//fakebutton = Button Box(" ",<< Style("underline"), << set function(ok_button << click)),
rb = Radio Box(
{"Option 1", "Option 2"}, << Set(2)
),
Panelbox("Actions",
Hlistbox(
ok_button = button box("OK", okPushed = 1; sel = rb << get selected),
cancel_button = button box("Cancel", okPushed = 0; stop();),
)
),
);
if(okPushed == 0, stop());
show(sel);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Default button selection/highlight in modal window
Currently using the same workaround as mentioned on the opening message with fakebutton:
Names Default To Here(1);
okPushed = 0;
nw = New Window("Modal window", << modal, Show toolbars(0), Show menu(0),
fakebutton = Button Box(" ",<< Style("underline"), << set function(ok_button << click)),
rb = Radio Box(
{"Option 1", "Option 2"}, << Set(2)
),
Panelbox("Actions",
Hlistbox(
ok_button = button box("OK", okPushed = 1; sel = rb << get selected),
cancel_button = button box("Cancel", okPushed = 0; stop();),
)
),
);
if(okPushed == 0, stop());
show(sel);
Also something similar to this could most likely be used as a workaround Set focus on text edit box
Also created new wish: Allow <<SetFocus to be used with interactive display elements (TextEditBox, Button...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Default button selection/highlight in modal window
Can you put the OK button at the top of the window?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Default button selection/highlight in modal window
yes...here is an example
Names Default To Here( 1 );
nw = New Window("At the Top", << modal,
v list box(
button box("OK", nw << close window ),
spacer box(size(0,25)),
text box(" at the bottom")
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Default button selection/highlight in modal window
Moving the buttons to top could be one option to avoid adding empty button to the top.
Quickly testing it seems that if I don't make the New window modal, enter key press will press OK button instead of the first option of radio buttons.
Names Default To Here(1);
okPushed = 0;
nw = New Window("Modal window", Show toolbars(0), Show menu(0),
rb = Radio Box(
{"Option 1", "Option 2"}, << Set(2)
),
Panelbox("Actions",
Hlistbox(
ok_button = button box("OK", okPushed = 1; sel = rb << get selected; nw << close window;),
cancel_button = button box("Cancel", okPushed = 0; nw << close window;)
)
),
);
nw << on close(
if(okPushed == 0, show(sel, okPushed); stop(),
show(sel, okPushed);
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Default button selection/highlight in modal window
Currently using the same workaround as mentioned on the opening message with fakebutton:
Names Default To Here(1);
okPushed = 0;
nw = New Window("Modal window", << modal, Show toolbars(0), Show menu(0),
fakebutton = Button Box(" ",<< Style("underline"), << set function(ok_button << click)),
rb = Radio Box(
{"Option 1", "Option 2"}, << Set(2)
),
Panelbox("Actions",
Hlistbox(
ok_button = button box("OK", okPushed = 1; sel = rb << get selected),
cancel_button = button box("Cancel", okPushed = 0; stop();),
)
),
);
if(okPushed == 0, stop());
show(sel);
Also something similar to this could most likely be used as a workaround Set focus on text edit box
Also created new wish: Allow <<SetFocus to be used with interactive display elements (TextEditBox, Button...)