A GtkToggleButton
is a GtkButton
which will remain 'pressed-in' when
clicked. Clicking again will cause the toggle button to return to its
normal state. A toggle button is created by calling either gtkToggleButtonNew
or
gtkToggleButtonNewWithLabel
. If using the former, it is advisable to
pack a widget, (such as a GtkLabel
and/or a GtkPixmap
), into the toggle
button's container. (See GtkButton
for more information). The state of a GtkToggleButton
can be set specifically using
gtkToggleButtonSetActive
, and retrieved using
gtkToggleButtonGetActive
. To simply switch the state of a toggle button, use gtk_toggle_button_toggled. Creating two GtkToggleButton
widgets.
# Let's make two toggle buttons
make_toggles <- function() {
dialog <- gtkDialog(show = F)
toggle1 <- gtkToggleButton("Hi, i'm a toggle button.") ## Makes this toggle button invisible
toggle1$setMode(TRUE) gSignalConnect(toggle1, "toggled", output_state)
dialog[["actionArea"]]$packStart(toggle1, FALSE, FALSE, 2) toggle2 <- gtkToggleButton("Hi, i'm another button.")
toggle2$setMode(FALSE)
gSignalConnect(toggle2, "toggled", output_state)
dialog[["actionArea"]]$packStart(toggle2, FALSE, FALSE, 2) dialog$showAll()
}