Last data update: 2014.03.03

R: A list selection dialog box
dlgListR Documentation

A list selection dialog box

Description

Select one or several items in a list.

Usage

dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    ..., gui = .GUI)
   
## These should not be called directly
## S3 method for class 'gui'
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    ..., gui = .GUI)
## S3 method for class 'textCLI'
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    ..., gui = .GUI)
## S3 method for class 'nativeGUI'
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    ..., gui = .GUI)

Arguments

choices

the list of items. It is coerced to character strings.

preselect

a list of preselections, or NULL (then, the first element is selected in the list). Preselections not in choices are tolerated (and disregarded, of course).

multiple

is it a multiple selection dialog box?

title

the title of the dialog box, or NULL.

...

pass further arguments to methods.

gui

the 'gui' object concerned by this dialog box.

Value

The modified 'gui' object is returned invisibly. A list with selected items, or a character vector of length 0 if the dialog box was cancelled is available from gui$res (see examples).

Author(s)

Philippe Grosjean (phgrosjean@sciviews.org)

Examples

## Select a month
res <- dlgList(month.name, multiple = TRUE)$res
if (!length(res)) {
  cat("You cancelled the choice\n")
} else {
  cat("You selected:\n")
  print(res)
}

Results