Learn R Programming

svDialogs (version 1.0.0)

dlg_input: Modal dialog to input a string or a value.

Description

Prompt for some data in a modal dialog box.

Usage

dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)

dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)

# S3 method for gui dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)

# S3 method for textCLI dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)

# S3 method for nativeGUI dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)

Arguments

message

The message to display in the dialog box. Use \n for line break, or provide a vector of character strings, one for each line.

default

The default value in the text box. Single string or NULL.

...

Pass further arguments to methods.

gui

The 'gui' object concerned by this dialog box.

Value

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).

See Also

dlg_list(), dlg_form(), dlg_message()

Examples

Run this code
# 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")
}
# }

Run the code above in your browser using DataLab