Contents Up Previous Next

wxToggleButton

wxToggleButton is a button that stays pressed when clicked by the user. In other words, it is similar to wxCheckBox in functionality but looks like a wxButton.

You can see wxToggleButton in action in the sixth page of the controls sample.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/tglbtn.h>

Window styles

There are no special styles for wxToggleButton.

See also window styles overview.

Event handling

EVT_TOGGLEBUTTON(id, func) Handles a button click event.

See also

wxCheckBox, wxButton

Members

wxToggleButton::wxToggleButton
wxToggleButton::~wxToggleButton
wxToggleButton::Create
wxToggleButton::GetValue
wxToggleButton::SetValue


wxToggleButton::wxToggleButton

wxToggleButton()

Default constructor.

wxToggleButton(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")

Constructor, creating and showing a toggle button.

Parameters

parent

id

label

pos

size

style

validator

name

See also

wxToggleButton::Create, wxValidator


wxToggleButton::~wxToggleButton

~wxToggleButton()

Destructor, destroying the toggle button.


wxToggleButton::Create

bool Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")

Creates the toggle button for two-step construction. See wxToggleButton::wxToggleButton for details.


wxToggleButton::GetValue

bool GetValue() const

Gets the state of the toggle button.

Return value

Returns true if it is pressed, false otherwise.


wxToggleButton::SetValue

void SetValue(const bool state)

Sets the toggle button to the given state. This does not cause a EVT_TOGGLEBUTTON event to be emitted.

Parameters

state