Using setUI()
is the preferred way to set a property in a gui
object.
Similarly, startUI()
should be used to indicate that an UI action requiring
user input is initiated (say, a modal input or file selection dialog box).
setUI(..., gui = .GUI)
# S3 method for gui
setUI(fun, call, args, res, widgets, status, msg = NULL, ..., gui = .GUI)
startUI(..., gui = .GUI)
# S3 method for gui
startUI(
fun,
call,
default,
widgets = NULL,
status = "busy-modal",
msg = "Displaying a modal dialog box",
msg.no.ask = "A modal dialog box was by-passed",
...,
gui = .GUI
)
Any other property of the GUI, provided as named arguments.
A gui
object.
The name of the calling function. Only required if call
is
provided.
The call in the generic as obtained by match.call()
.
A list with checked and/or reworked arguments for a method. The generic can do this work, so that code does not need to be duplicated in all its methods.
Any data returned by the GUI (the results).
The class name of the current widgets implementation.
Description of the current GUI status. Could be "ok", "busy",
"busy-modal" (a modal dialog box is currently displayed), "by-passed" (the
GUI was by-passed because dont_ask()
returns TRUE
), "error",
or any other status indicator suitable for the current state of your GUI.
The message that explains the status. Cannot be provided without status.
The default value to return if the UI is by-passed because in
non interactive mode, or ask is FALSE
.
The message that explains the status in case the UI is by-passed.
gui
: Set an UI property for a gui
object.
gui
: Start an UI for a gui
object.
# Imagine you implement a new input box
# In your function, you have this code:
myInput <- function(default = "an answer", gui = .GUI) {
# Start a GUI action... or by-pass it!
if (gui$startUI("myInput", call = match.call(), default = default,
msg = "Displaying an input dialog box",
msg.no.ask = "An input dialog box was by-passed")) {
# Here the input dialog box is displayed and R waits for user feedback
# ... [your code here]
res <- "some results" # Imagine this is the text typed in the box
# When the input dialog box is closed, the function should do:
setUI(res = res, status = NULL)
}
invisible(gui)
}