A message box with icon, text, and one to three buttons.
Usage
dlgMessage(message, type = c("ok", "okcancel", "yesno", "yesnocancel"),
..., gui = .GUI)
msgBox(message)
okCancelBox(message)
## These should not be called directly
## S3 method for class 'gui'
dlgMessage(message, type = c("ok", "okcancel", "yesno", "yesnocancel"),
..., gui = .GUI)
## S3 method for class 'textCLI'
dlgMessage(message, type = c("ok", "okcancel", "yesno", "yesnocancel"),
..., gui = .GUI)
## S3 method for class 'nativeGUI'
dlgMessage(message, type = c("ok", "okcancel", "yesno", "yesnocancel"),
..., 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.
type
the type of dialog box: 'ok', 'okcancel', 'yesno' or
'yesnocancel'.
...
pass further arguments to methods.
gui
the 'gui' object concerned by this dialog box.
Value
The modified 'gui' object is returned invisibly. A string with the name of
the button ("ok", "cancel", "yes" or "no") that the user pressed can be
obtained from gui$res (see example).
msgBox() just returns the name of the button (ok), while okCancelBox()
returns TRUE if ok was clicked or FALSE if cancel was clicked.
## A simple information box
dlgMessage("Hello world!")$res
## Ask to continue
dlgMessage(c("This is a long task!", "Continue?"), "okcancel")$res
## Ask a question
dlgMessage("Do you like apples?", "yesno")$res
## Idem, but one can interrupt too
res <- dlgMessage("Do you like oranges?", "yesnocancel")$res
if (res == "cancel") cat("Ah, ah! You refuse to answer!\n")
## Simpler version with msgBox and okCancelBox
msgBox("Information message") # Use this to interrupt script and inform user
if (okCancelBox("Continue?")) cat("we continue\n") else cat("stop it!\n")