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", controlEnv), 
                 method = "activate-item", modType = GdkModifierType[4], 
                 accelFlag = GtkAccelFlags[2])
     addSubMenuItem(menuName, labelText, action, ag=get("ag",controlEnv),
                 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:

     'createMainMenu', 'updateControlWindow'

_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")
       }

