模態窗口中的默認按鈕選擇/突出顯示是否可以將特定按鈕設置為模式窗口中的選定按鈕,以允許在Enter /空格鍵中使用該按鈕?
在我添加的示例腳本中,我希望默認選擇為模態窗口的“確定”按鈕,但默認情況下將其設置為單選框的第一個選擇(在本例中為“選項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);
腳本編寫回复:模態窗口中的默認按鈕選擇/突出顯示您可以將“確定”按鈕放在窗口頂部嗎?
回复:模態窗口中的默認按鈕選擇/突出顯示是的...這是一個例子
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")
)
)
回复:模態窗口中的默認按鈕選擇/突出顯示將按鈕移到頂部可能是避免在頂部添加空按鈕的一種選擇。
快速測試一下,如果我沒有將“新窗口”設置為模態,則按Enter鍵將按“確定”按鈕,而不是單選按鈕的第一個選項。
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);
);
);
回复:模式窗口中的默認按鈕選擇/突出顯示當前使用與使用falsebutton的開幕消息中提到的相同的解決方法:
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);同樣,與此類似的東西很可能被用作解決方法將重點放在文字編輯框上
還創造了新的願望:允許<< SetFocus與交互式顯示元素(TextEditBox,Button ...)一起使用