\HeaderA{addMenuItem}{Add menu and submenu items to the menu from R command line}{addMenuItem}
\aliasA{addSubMenuItem}{addMenuItem}{addSubMenuItem}
\keyword{interface}{addMenuItem}
\begin{Description}\relax
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).
\end{Description}
\begin{Usage}
\begin{verbatim}
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], ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{menuName}] A character string giving the name of the menu. This is
displayed on the menu and is used to access the item. 
\item[\code{labelText}] The text shown on the menu item. 
\item[\code{ag}] The Gtk accelerator group.
\item[\code{method}] The Gtk method, which occurs in response to accelerator keys.
\item[\code{modType}] the GdkModifierType 
\item[\code{accelFlag}] the GdkAccelFlags 
\item[\code{action}] the current action to set \code{action} in
\code{controlEnv} 
(this function will be called in response to
activation of menu item)
\item[\code{...}] any extra parameters that will be needed in the
function, \code{action} 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
To add a new menu item, first call \code{addMenuItem} to create the
menu item, and then call \code{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, \code{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 \dots parameter.  This function will be called in 
updateControlWindow, using do.call.
\end{Details}
\begin{Value}
addSubMenuItem returns the new GtkMenuItem object that was created or
if an error occurred, then addSubMenuItem returns an empty list.
\end{Value}
\begin{Author}\relax
Elizabeth Whalen
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{addToKeyVals}{addToKeyVals}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  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")
  }
\end{ExampleCode}
\end{Examples}

