Prompt for some data in a modal dialog box.
dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)
dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)
# S3 method for gui
dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)
# S3 method for textCLI
dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)
# S3 method for nativeGUI
dlg_input(
message = "Enter a value",
default = "",
rstudio = getOption("svDialogs.rstudio", TRUE),
...,
gui = .GUI
)
The message to display in the dialog box. Use \\n
for
line break, or provide a vector of character strings, one for each line.
The default value in the text box. Single string or NULL
.
Pass further arguments to methods.
The 'gui' object concerned by this dialog box.
Logical. Should 'RStudio' dialog boxes automatically be used
if available? If FALSE
, force using OS dialog boxes, but only in
'RStudio Desktop' (ignored in 'RStudio Server'). Can be changed globally
with options(svDialogs.rstudio = TRUE|FALSE)
. TRUE
by default.
The modified 'gui' object is returned invisibly. The text entered by
the user at the input box, or an empty string if the dialog box was cancelled
can be obtained from gui$res
(see example).
The 'RStudio' version of this dialog box does not allow for an empty
string. So, for better portability, try never to expect an empty string from
the user (the 'Cancel'
button is there to dismiss the dialog box).
On MacOS, single and double quotes are temporarily replaced by their slanted
versions (unicode characters u3032 and u2033, respectively) because the
command that triggers the dialog box does not allow quotes inside strings.
Regular quotes are reset on the output. This is the only hack we found that
was working. Better solutions are welcome!