# wxToggleButton Class Reference
[Controls]

`#include </home/work/projects/wx/2.9/wx/interface/wx/tglbtn.h>`

Inheritance diagram for wxToggleButton:
[legend]

## Detailed Description

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.

Since wxWidgets version 2.9.0 this control emits an update UI event.

You can see wxToggleButton in action in Controls Sample.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxCommandEvent& event)

Event macros for events emitted by this class:

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

##

Library: wxCore
Category: Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  wxCheckBox, wxButton, wxBitmapToggleButton

## Public Member Functions

| 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=wxDefaultValidator, const wxString &name=wxCheckBoxNameStr)
| Constructor, creating and showing a toggle button.
virtual | ~wxToggleButton ()
| Destructor, destroying the toggle button.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &val=wxDefaultValidator, const wxString &name=wxCheckBoxNameStr)
| Creates the toggle button for two-step construction.
virtual bool | GetValue () const
| Gets the state of the toggle button.
virtual void | SetValue (bool state)
| Sets the toggle button to the given state.

List of all members.

## Constructor & Destructor Documentation

wxToggleButton::wxToggleButton | ( |  | ) |

Default constructor.

wxToggleButton::wxToggleButton | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxValidator & | val = `wxDefaultValidator`,
|  | const wxString & | name = `wxCheckBoxNameStr` |
| ) |  |  |

Constructor, creating and showing a toggle button.

Parameters:

  | parent | Parent window. Must not be NULL.
  | id | Toggle button identifier. The value wxID_ANY indicates a default value.
  | label | Text to be displayed next to the toggle button.
  | pos | Toggle button position. If wxDefaultPosition is specified then a default position is chosen.
  | size | Toggle button size. If wxDefaultSize is specified then a default size is chosen.
  | style | Window style. See wxToggleButton.
  | val | Window validator.
  | name | Window name.

See also:
  Create(), wxValidator

virtual wxToggleButton::~wxToggleButton | ( |  | ) | `[virtual]`

Destructor, destroying the toggle button.

## Member Function Documentation

bool wxToggleButton::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxValidator & | val = `wxDefaultValidator`,
|  | const wxString & | name = `wxCheckBoxNameStr` |
| ) |  |  |

Creates the toggle button for two-step construction.

See wxToggleButton() for details.

virtual bool wxToggleButton::GetValue | ( |  | ) | const`[virtual]`

Gets the state of the toggle button.

Returns:
  Returns true if it is pressed, false otherwise.

virtual void wxToggleButton::SetValue | ( | bool | state | ) | `[virtual]`

Sets the toggle button to the given state.

This does not cause a `EVT_TOGGLEBUTTON` event to be emitted.

Parameters:

  | state | If true, the button is pressed.

|  | [ top ]