gcheckboxgroup {gWidgets2} | R Documentation

## Constructor for checkbox group. A linked group of checkboxes, but not exclusive.

### Description

Constructor for checkbox group. A linked group of checkboxes, but not exclusive.

generic for toolkit dispatch

Change handler for a `GCheckboxGroup`p is called when any of the checkboxes changes state.

The `svalue` methods refer to the selected values. By default these are the item values, coerced to characterq. When `index=TRUE` is specified, then the index is returned as an integer vector. For setting, one may also use a vector of logicals (which is recycled) for the index.

### Usage

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

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

    ## S3 method for class 'GCheckboxGroup'
    addHandlerChanged(obj, handler, action = NULL, ...)

    ## S3 method for class 'GCheckboxGroup'
    svalue(obj, index = NULL, drop = NULL, ...)

### Arguments

`items` | checkbox labels
`checked` | logical. Are values checked
`horizontal` | logical. If true displayed horizontally, else vertically
`use.table` | logical. If supported, and `TRUE` then uses a table widget with scrollbars
`handler` | A handler assigned to the default change signal. Handlers are called when some event triggers a widget to emit a signal. For each widget some default signal is assumed, and handlers may be assigned to that through `addHandlerChanged` or at construction time. Handlers are functions whose first argument, `h` in the documentation, is a list with atleast two components `obj`, referring to the object emitting the signal and `action`, which passes in user-specified data to parameterize the function call. Handlers may also be added via `addHandlerXXX` methods for the widgets, where `XXX` indicates the signal, with a default signal mapped to `addHandlerChanged` (cf. `addHandler` for a listing). These methods pass back a handler ID that can be used with `blockHandler` and `unblockHandler` to suppress temporarily the calling of the handler.
`action` | User supplied data passed to the handler when it is called
`container` | A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.)
`...` | These values are passed to the `add` method of the parent container. Examples of values are `expand`, `fill`, and `anchor`, although they're not always supported by a given widget. For more details see add. Occasionally the variable arguments feature has been used to sneak in hidden arguments to toolkit implementations. For example, when using a widget as a menubar object one can specify a parent argument to pass in parent information, similar to how the argument is used with gaction and the dialogs.
`toolkit` | Each widget constructor is passed in the toolkit it will use. This is typically done using the default, which will lookup the toolkit through `guiToolkit`.
`obj` | receiver object
`index` | NULL or logical. If `TRUE` and widget supports it an index, instead of a value will be returned.
`drop` | NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means.

### Value

Returns an object of class `GCheckboxGroup` for which the following methods are overridden:

- `svalue` Return the selected values or an empty character vector. If `index=TRUE`, returns indices of selected values.

- `svalue<-` Set the selected values one of three ways: by label name, by a logical variable indicating which are selected (if ambigous, logical wins), if `index=TRUE` by the indices to select.

- `[` returns labels

- `[<-` set the label values. Should be able to shorten or lengthen list

### Examples

    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)))

    }

[Package gWidgets2 version 1.0-8 Index]