addMenuItem {iSPlot}R Documentation

Add menu and submenu items to the menu from R command line

Description

addMenuItem adds a menu item to the main menu on the control window after the main menu has already been created. addMenuItem is meant to be called from the R command line when the user wants to add a new menu item to the main menu. addSubMenuItem adds a sub menu item to an already existing menu (such as file, edit, display or viewMode).

Usage

addMenuItem(menuName, labelText, accelGroup = get("ag", controlEnv), 
            method = "activate-item", modType = GdkModifierType[4], 
            accelFlag = GtkAccelFlags[2])
addSubMenuItem(labelText, curAction, menuName, ag=get("ag",controlEnv),
            method="activate", modType=GdkModifierType[3], 
            accelFlag=GtkAccelFlags[2], ...)

Arguments

menuName character string giving the name of the menu (this is used to later access the menu object from the environment variable, menus)
labelText the text shown on the menu item
accelGroup the gtk accelerator group
method the gtk method, which occurs in response to accelerator keys
modType the GdkModifierType
accelFlag the GdkAccelFlags
curAction the current action to set curAction in controlEnv (this should be the function that will be called in response to activation of menu item)
ag the gtk accelerator group
... any extra parameters that will be needed in the function, updateControlWindow

Details

To add a new menu item, first call addMenuItem and then call addSubMenuItem to add sub menu items to the new menu item.

When adding a sub menu item, curAction will be the name of the function that will be called when the menu item is activated. This function, given as a character string to curAction, can have parameters. Any extra parameters will be placed in the ... parameter. This function will be called in updateControlWindow, using do.call.

Value

addSubMenuItem returns the new GtkMenuItem object that was created or if an error occurred, then addSubMenuItem returns an empty list.

Author(s)

Elizabeth Whalen

See Also

createMainMenu, updateControlWindow

Examples

  if (interactive())
  {
    createControlWindow()
    addMenuItem("new","_New")

    testfun<-function()
    {
      w<-gtkWindow(show=FALSE)
      lab<-gtkLabel("It works!")
      w$Add(lab)
      w$Show()
    }

    newMenuItem<-addSubMenuItem("Diff_erent  Ctrl+E","testfun","new")
  }

[Package iSPlot version 1.0.3 Index]