buttonItem: Button item to initiate an action

Description Usage Arguments Value See Also Examples

Description

While dialogs have a buttons property for the main buttons, this item allows other buttons to be used within a dialog. One must define an action (a callback) to call when the button is clicked. There are some issues with how this method is defined and where it is evaluated.

Usage

1
2
buttonItem(value = "button label", action = NULL, name, label = name,
  help = "", tooltip = "", attr, model, editor, ...)

Arguments

value

Default value for the model

action

function to call when clicked. Signature is function(., h, ...) {} (like gWidgets with extra leading .). The "." is the button item, not the itemgroup or dialog that this item may be a part of. When that is the case, .$parent refers to the parent itemgroup or dialog. The evaluation environment is not that where the action is defined. This can lead to unexpected sources of error.

name

Required name for object. Names should be unique within a group of items

label

Optional label, default value is the name. Use "" to have not label text.

help

Optional help string

tooltip

Optional tooltip to display

attr

A list of attributes to pass to widget on construction. Eg. attr=list(size=c(100,200))

model

Optional model. Useful if one wishes to use same model for multiple views

editor

Specification of editor (a view) to override default

...

Passed to parent proto object during call to proto

Value

A proto object. Call obj$show_help() to view its methods and properties.

See Also

Item

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## basic button. Note the extra "." compared to gWidgets handler
b <- buttonItem("click me", action=function(.,h,...) {
       print("hi")

     })
## An example within a dialog
dlg <- aDialog(items=list(
                a = stringItem(""),
                b = buttonItem("Click me", label="", action=function(., h, ...) {
                  galert(sprintf("Item a is \%s\n", .$parent$get_a()))
                })
                ),
              title="A dialog with a button item",
              buttons=c()               # no standard buttons
              )
   ## Not run: dlg$make_gui()

traitr documentation built on May 2, 2019, 3:32 p.m.