模态窗口中的默认按钮选择/突出显示是否可以在模态窗口中将特定按钮设置为选定按钮以允许通过输入/空格键使用该按钮?
在我添加的示例脚本中,我希望默认选择是模态窗口的“确定”按钮,但默认情况下它被设置为单选框的第一个选择(在本例中为“选项 1”),我还没有想到了解如何更改它。 我设法通过在新窗口(默认选择)中创建假按钮作为第一个元素来做到这一点,该按钮单击“确定”按钮,但我觉得这是一种让它工作的方式(在示例脚本中已注释掉)。
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);
脚本回复:模态窗口中的默认按钮选择/突出显示目前使用与 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);与此类似的东西也很可能用作解决方法将焦点设置在文本编辑框上
还创造了新愿望:允许 <
回复:模态窗口中的默认按钮选择/突出显示将按钮移动到顶部可能是避免在顶部添加空按钮的一种选择。
快速测试似乎如果我不使新窗口模式,输入键按下将按下 OK 按钮而不是单选按钮的第一个选项。
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);
);
);
回复:模态窗口中的默认按钮选择/突出显示是的...这是一个例子
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")
)
)
回复:模态窗口中的默认按钮选择/突出显示你能把确定按钮放在窗口的顶部吗?