模態窗口中的默認按鈕選擇/突出顯示是否可以在模態窗口中將特定按鈕設置為選定按鈕以允許通過輸入/空格鍵使用該按鈕?
在我添加的示例腳本中,我希望默認選擇是模態窗口的“確定”按鈕,但默認情況下它被設置為單選框的第一個選擇(在本例中為“選項 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")
)
)
回复:模態窗口中的默認按鈕選擇/突出顯示你能把確定按鈕放在窗口的頂部嗎?