[rkward] rkward/rbackend/rpackages/rkward: Change default parameter to match better with R's askYesNo()

Thomas Friedrichsmeier null at kde.org
Tue May 8 08:50:54 UTC 2018


Git commit a2f7a7653b12b8f2b8e9933b74d8c73c92193a56 by Thomas Friedrichsmeier.
Committed on 08/05/2018 at 08:50.
Pushed by tfry into branch 'master'.

Change default parameter to match better with R's askYesNo()

M  +8    -4    rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
M  +4    -3    rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd

https://commits.kde.org/rkward/a2f7a7653b12b8f2b8e9933b74d8c73c92193a56

diff --git a/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
index 3cdd4b1e..f7d8f807 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
@@ -27,8 +27,9 @@
 #' @param button.cancel a string used for the text label of the \bold{Cancel} button.
 #'   This behaves similar to \code{button.yes}, including the meaning of the
 #'   default value "cancel".
-#' @param default.button The button will be the default (selected if the user
-#'   simply pressed enter.
+#' @param default The expected or "safe" default response (e.g. \code{TRUE} for "Yes button").
+#'   The corresponding button will focused, so that it will become selected option,
+#'   if the user simply presses enter.
 #' @param wait a logical (not NA) indicating whether the R interpreter should
 #'   wait for the user's action, or run it asynchronously.
 #' @param list a vector, coerced into a character vector.
@@ -75,8 +76,11 @@
 # to disable a button, set it to ""
 #' @export
 #' @rdname rk.show.messages
-"rk.show.question" <- function (message, caption = gettext("Question"), button.yes = "yes", button.no = "no", button.cancel = "cancel", default.button=button.yes) {
-	res <- .Call ("rk.dialog", caption, message, button.yes, button.no, button.cancel, default.button, TRUE, PACKAGE="(embedding)")
+"rk.show.question" <- function (message, caption = gettext("Question"), button.yes = "yes", button.no = "no", button.cancel = "cancel", default=TRUE) {
+	if (isTRUE (default)) default_button <- button.yes
+	else if (identical (default, FALSE)) default_button <- button.no
+	else default_button <- button.cancel
+	res <- .Call ("rk.dialog", caption, message, button.yes, button.no, button.cancel, default_button, TRUE, PACKAGE="(embedding)")
 	if (res > 0) return (TRUE)
 	else if (res < 0) return (FALSE)
 	else return (NULL)	# cancelled
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd b/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
index 1433ee32..62005ce4 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
@@ -11,7 +11,7 @@
 rk.show.message(message, caption = gettext("Information"), wait = TRUE)
 
 rk.show.question(message, caption = gettext("Question"), button.yes = "yes",
-  button.no = "no", button.cancel = "cancel", default.button = button.yes)
+  button.no = "no", button.cancel = "cancel", default = TRUE)
 
 rk.select.list(list, preselect = NULL, multiple = FALSE, title = NULL)
 }
@@ -37,8 +37,9 @@ default value "no".}
 This behaves similar to \code{button.yes}, including the meaning of the
 default value "cancel".}
 
-\item{default.button}{The button will be the default (selected if the user
-simply pressed enter.}
+\item{default}{The expected or "safe" default response (e.g. \code{TRUE} for "Yes button").
+The corresponding button will focused, so that it will become selected option,
+if the user simply presses enter.}
 
 \item{list}{a vector, coerced into a character vector.}
 



More information about the rkward-tracker mailing list