Open jalvesaq opened 8 years ago
I wish that pressing the <Enter> key would make the ginput() consider that the "OK" button was pressed. However, this does not happen. So, I developed a possible replacement for ginput():
<Enter>
ginput()
library(gWidgetsRGtk2) x <- "No name" Input <- function(prnt, lbl, callback) { idlg <- gwindow(title = gettext("input", domain = "R-RQDA"), height = 20, parent = prnt, visible = FALSE) vbox <- ggroup(horizontal = FALSE, container = idlg) glabel(lbl, container = vbox, anchor = c(-1, 1)) itxt <- gedit(width = 25, container = vbox, anchor = c(-1, 1)) hbox <- ggroup(container = vbox) addSpring(hbox) cnBt <- gbutton(gettext("Cancel", domain = "R-RQDA"), container = hbox) okBt <- gbutton(gettext("OK", domain = "R-RQDA"), container = hbox) onOK <- function(...){ callback(svalue(itxt)) dispose(idlg) } onCancel <- function(...){ dispose(idlg) } addHandlerChanged(itxt, onOK) addHandlerChanged(okBt, onOK) addHandlerChanged(cnBt, onCancel) visible(idlg) <- TRUE } # x <- ginput("Name of file:") Input(NULL, "Name of file:", function(v) { x <<- v })
I wish that pressing the
<Enter>
key would make theginput()
consider that the "OK" button was pressed. However, this does not happen. So, I developed a possible replacement forginput()
: