Search code examples
rgwidgets

R gWidgets toggle item value in menu list


How do I create a toggle value item inside a gmenu object? For example, in Eclipse menu, Project -> Build Automatically option, I can toggle its value by clicking on it. A check mark will be displayed in front of it.

enter image description here


Solution

  • With gWidgets2 this can be done. Here is an example that can be improved upon:

    library(gWidgets2) w <- gwindow() mlist <- list(file=list( cb=gcheckbox("check", parent=w, handler=function(h, ...) print(svalue(h$obj))), act=gaction("hi", handler=function(...) print("hi"), parent=w), gseparator(parent=w), rb = gradio(letters[1:3], parent=w, handler=function(h, ...) print(svalue(h$obj))) )) gmenu(mlist, cont=w)