檢視原始碼 wxRadioButton (wx v2.4.3)
單選按鈕項目是一個按鈕,通常表示數個互斥選項中的其中一個。
它在一個(通常是)圓形按鈕旁邊有一個文字標籤。
您可以透過為群組中的第一個指定 wxRB_GROUP
來建立一組互斥的單選按鈕。當建立另一個單選按鈕群組,或沒有更多單選按鈕時,群組即結束。
樣式
此類別支援以下樣式
wxRB_GROUP:標記新單選按鈕群組的開始。
wxRB_SINGLE:在某些情況下,不連續的同層級單選按鈕會觸發 Windows (僅限) 中的掛起錯誤。如果發生這種情況,請新增此樣式以將按鈕標記為不屬於群組,並自行實作互斥群組行為。
請參閱
此類別繼承自以下類別,並可使用其函式
wxWidgets 文件:wxRadioButton
事件
此類別發出的事件類型
摘要
型別
-type wxRadioButton() :: wx:wx_object().
函式
-spec create(This, Parent, Id, Label) -> boolean() when This :: wxRadioButton(), Parent :: wxWindow:wxWindow(), Id :: integer(), Label :: unicode:chardata().
-spec create(This, Parent, Id, Label, [Option]) -> boolean() when This :: wxRadioButton(), Parent :: wxWindow:wxWindow(), Id :: integer(), Label :: unicode:chardata(), Option :: {pos, {X :: integer(), Y :: integer()}} | {size, {W :: integer(), H :: integer()}} | {style, integer()} | {validator, wx:wx_object()}.
建立用於兩步驟建構的選擇項。
請參閱 new/4
以取得更多詳細資訊。
-spec destroy(This :: wxRadioButton()) -> ok.
銷毀物件
-spec getValue(This) -> boolean() when This :: wxRadioButton().
如果單選按鈕已選取,則傳回 true,否則傳回 false。
-spec new() -> wxRadioButton().
預設建構子。
請參閱:create/5
-spec new(Parent, Id, Label) -> wxRadioButton() when Parent :: wxWindow:wxWindow(), Id :: integer(), Label :: unicode:chardata().
-spec new(Parent, Id, Label, [Option]) -> wxRadioButton() when Parent :: wxWindow:wxWindow(), Id :: integer(), Label :: unicode:chardata(), Option :: {pos, {X :: integer(), Y :: integer()}} | {size, {W :: integer(), H :: integer()}} | {style, integer()} | {validator, wx:wx_object()}.
建構子,建立並顯示單選按鈕。
請參閱:create/5
-spec setValue(This, Value) -> ok when This :: wxRadioButton(), Value :: boolean().
將單選按鈕設定為選取或未選取狀態。
這不會導致發出 wxEVT_RADIOBUTTON
事件。
如果單選按鈕屬於單選群組,則群組中只能選取一個按鈕,因此此方法只能在 value
設定為 true 時呼叫。若要取消選取群組中的單選按鈕,您必須選取同一群組中的另一個按鈕。
注意:在 MSW 下,焦點所在的單選按鈕始終處於選取狀態,即其值為 true。反之,呼叫 SetValue(true)
也會將焦點設定到單選按鈕,如果焦點先前在同一群組中的另一個單選按鈕上 - 因為否則將其設定為 on 將不起作用。