R: Widget to allow multiple selection from a vector of items

gcheckboxgroup {gWidgets} | R Documentation

## Widget to allow multiple selection from a vector of items

### Description

Widgets to select one (or several) from a given vector of items. These are a radio group where all values are shown at once, but only one may be selected; a checkbox group where more than one may be selected; and a combo box (or droplist) where initially only a single value is shown, and the others are a mouse click away,

### Usage

    gcheckboxgroup(items, checked = FALSE,  horizontal = FALSE, use.table=FALSE,
        handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit())

### Arguments

`items` | Vector of values to select from
`checked` | A logical vector indicating initial values.
`horizontal` | A logical specifying the layout for gradio and gcheckboxgroup
`handler` | Called when selection is changed
`use.table` | If `TRUE` a table with checkboxes will be used instead (toolkit depending) so that one can scroll through the values
`action` | Passed to handler when called.
`container` | Optional container to attach widget to
`...` | Passed to `add` method of container
`toolkit` | Which GUI toolkit to use

### Details

The `svalue` method returns the selected values by name. If the extra argument `index=TRUE` is specified, the indices of the selected values is given.

The `svalue<-` method can be used to set the selected value. This widget is a cross between a checkbox and a radio button group. As such, there are different ways to specify the state. As with a checkbox, the argument can be a logical vector indicating which checkboxes are to be checked (recycling is done). As with a radio button group, the value can be a character vector indicating by label which checkboxes are to be checked; or if the `index=TRUE` argument is given, a vector of indices for those checkboxes to be checked.

The `"["` method refers to the vector defining the items.

The `"[<-"` method can be used to change the vector defining the items. The length should be the same as the original, although in some toolkits this isn't necessary.

The `"length"` method returns the number of items.

### See Also

A checkboxgroup is one of several ways to select a value of a set of items. See also

`gcheckbox`, `gradio`, `gcombobox`, and `gtable`.

Methods for gComponent objects are detailed in `gWidgets-methods`.

Event Handlers are detailed in `gWidgets-handlers`.

### Examples

    ## Not run:
      flavors <- c("vanilla", "chocolate", "strawberry")

      f <- function(h,...) print(
          paste("Yum",
          paste(svalue(h$obj),collapse=" and "),
          sep = " "))

      w <- gwindow("checkbox example")
      gp <- ggroup(container=w)
      glabel("Favorite flavors:",container=gp)
      cbg <- gcheckboxgroup(flavors, container=gp, handler=f)

      svalue(cbg) <- c(TRUE, FALSE, TRUE)
      svalue(cbg)
      svalue(cbg) <- "vanilla"
      svalue(cbg, index=TRUE) <- 1:2
      cbg[3] <- "raspberry"

      ## use a table to display (toolkit specific) so that scrollars can be used
      cbg <- gcheckboxgroup(letters, container=gwindow(), use.table=TRUE)

    ## End(Not run)

[Package gWidgets version 0.0-54 Index]