addMenuItem              package:iSPlot              R Documentation

_A_d_d _m_e_n_u _a_n_d _s_u_b_m_e_n_u _i_t_e_m_s _t_o _t_h_e _m_e_n_u _f_r_o_m _R _c_o_m_m_a_n_d _l_i_n_e

_D_e_s_c_r_i_p_t_i_o_n:

     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).

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

menuName: A character string giving the name of the menu. This is
          displayed on the menu and is used to access the item. 

labelText: The text shown on the menu item. 

      ag: The Gtk accelerator group.

  method: The Gtk method, which occurs in response to accelerator keys.

 modType: the GdkModifierType 

accelFlag: the GdkAccelFlags 

  action: the current action to set 'action' in 'controlEnv'  (this
          function will be called in response to activation of menu
          item)

     ...: any extra parameters that will be needed in the function,
          'action' 

_D_e_t_a_i_l_s:

     To add a new menu item, first call 'addMenuItem' to create the
     menu item, and then call 'addSubMenuItem' to add sub menu items to
     the new menu item. There is some checking to see if the item
     already exists. 

     When adding a sub menu item, 'action' is 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.

_V_a_l_u_e:

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

_A_u_t_h_o_r(_s):

     Elizabeth Whalen

_S_e_e _A_l_s_o:

     'addToKeyVals'

_E_x_a_m_p_l_e_s:

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

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

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

