单击“取消”时阻止关闭窗口。
这很有效。
library(gWidgets)
options("guiToolkit"="RGtk2")
## block closing of window
win <- gwindow("Window example")
addHandlerUnrealize(win, handler = function(h,...) {
val <- gconfirm("Really close window", parent=h$obj)
if(as.logical(val))
return(FALSE) # destroy
else
return(TRUE) # don't destroy
})
这不起作用。
library(gWidgets2)
options("guiToolkit"="RGtk2")
## block closing of window
win <- gwindow("Window example")
addHandlerUnrealize(win, handler = function(h,...) {
val <- gconfirm("Really close window", parent=h$obj)
if(as.logical(val))
return(FALSE) # destroy
else
return(TRUE) # don't destroy
})
我在addHandlerUnrealize中使用了tryCatch({}),返回错误信息显示:
(Rterm.exe:12636):Gtk-CRITICAL **:gtk_tree_view_unref_tree_helper:断言`node!= NULL'失败