dlg_input | R Documentation |
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 class 'gui' dlg_input(message = "Enter a value", default = "", ..., gui = .GUI) ## S3 method for class 'textCLI' dlg_input(message = "Enter a value", default = "", ..., gui = .GUI) ## S3 method for class 'nativeGUI' dlg_input( message = "Enter a value", default = "", rstudio = getOption("svDialogs.rstudio", TRUE), ..., gui = .GUI )
message |
The message to display in the dialog box. Use |
default |
The default value in the text box. Single string or |
... |
Pass further arguments to methods. |
gui |
The 'gui' object concerned by this dialog box. |
rstudio |
Logical. Should 'RStudio' dialog boxes automatically be used
if available? If |
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!
dlg_list()
, dlg_form()
, dlg_message()
## Not run: # Ask something... user <- dlg_input("Who are you?", Sys.info()["user"])$res if (!length(user)) {# The user clicked the 'cancel' button cat("OK, you prefer to stay anonymous!\n") } else { cat("Hello", user, "\n") } ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.