Learn R Programming

gWidgets2 (version 1.0-9)

gcheckbox: constructor for checkbox widget

Description

A checkbox widget is used to toggle the state of a labeled boolean variable. The main property of this widget is that state, not the label. This variable may be proxied in the usual way -- with a box that indicates or check if TRUE -- or through a toggle button.

The change handler for GCheckbox is called when the value toggles. You can inpsect the current value in the callback to have an action based on the state.

The object state is referred to by svalue as a logical (TRUE for checked). The svalue<- method ensures the value is a logical vector of length 1.

The item to select is referred to by the [ method, with only the first element being used.

Usage

gcheckbox(
  text = "",
  checked = FALSE,
  use.togglebutton = FALSE,
  handler = NULL,
  action = NULL,
  container = NULL,
  ...,
  toolkit = guiToolkit()
)

.gcheckbox( toolkit, text, checked = FALSE, use.togglebutton = FALSE, handler = NULL, action = NULL, container = NULL, ... )

# S3 method for GCheckbox addHandlerChanged(obj, handler, action = NULL, ...)

# S3 method for GCheckbox svalue (obj, index=NULL, ...) <- value

# S3 method for GCheckbox [ (x, i, j, ...) <- value

Arguments

text

label text

checked

is button selected

use.togglebutton

Use a toggle button (shows depressed) not a check box

handler

Callback called when toggle is changed.

action

passed to handler

container

parent container

...

passed to add method of container

toolkit

toolkit

obj

receiver object

index

ignored. Input is coerced to logical.

value

assignment value

x

checkbox object

i

item index

j

ignored

Value

Returns an object of class GCheckbox.

Examples

Run this code
# NOT RUN {
if(interactive()) {
  w <- gwindow("Selection widgets")
  g <- gvbox(cont=w)

  fl <- gformlayout(cont=g)
  gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox")
  gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio")
  gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group")

  bg <- ggroup(cont=g)
  gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue)))



}
# }

Run the code above in your browser using DataLab