the panel to which the menu should be attached should appear.
variable
the name of the variable whose value is set by the menu. (Renamed in 2.0 to variable from var as var is a reserved word.)
labels
the labels for the menu options. These values are returned through var. The menu is defined by a
list of lists of character strings. Each major menu heading should be the first item in the sub-lists with the
submenu items listed afterwards in the same list. Please see the example.
initval
the initial value of variable (optional). The initial value can also be specified in the call to rp.control.
action
the function which is called when a menu item is chosen.
foreground
this sets the colour of text e.g. "navy"
background
this sets the background colour of text e.g. "white"
font
this sets the text font e.g. "Arial"
name
the name of the widget - this is used by rp.widget.dispose
Details
The function action should take one argument, which should be the panel to which the listbox is attached.
The list for a menu consisting of "File" and "Edit" only would be defined as
list(list("File"), list("Edit")).
The list for a menu consisting of "File" with subitem "Quit", and "Edit" with subitems "Copy", "Cut" and "Paste", would be defined as
list(list("File", "Quit"), list("Edit", "Copy", "Cut", "Paste")).
Warning
The action function should return the panel. Without this assignment any widgets added or alterations made to panel parameters within the action function will be lost.
The action function must be defined before the rp.menu statement as it relies on the function already existing.
Note
The former argument parent has been discontinued in version 1.1.
References
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
See Also
rp.checkbox,rp.control
Examples
## Not run:
a <- rp.control()
# The action function has to come first so that it already exists for rp.menu,
# as it creates the callback functions on the fly it requires action to already
# be defined.
domenu <- function(panel) {
rp.messagebox(panel$menuchoice, title = "You chose")
panel
}
rp.menu(a, menuchoice, labels=list(list("File","Quit"),
list("Edit","Copy","Cut","Paste")), action=domenu)
## End(Not run)