a character string naming a menu item on an existing menu.
action
a character string describing the action when that menu is
selected, or "none" for no action. Use "enable" or
"disable" to activate or desactivate an existing menu item.
Details
On Windows, the function manages custom menus in RGui the same way as
winMenuAdd() and similar function do. Menus are added to the right
and new menu entries are added to the bottom of the menu. It is currently
not possible to add menus for Rterm.exe under Windows.
On Unix/Linux, under Gnome, you must install a little Gtk2 program called
ctxmenu
, as well as a few other utilities to manage these
menus. You can download corresponding files (GPL-2 license) and instructions
from http://www.sciviews.org/SciViews-R/ctxmenu.zip.
The R code only creates menu configuration files in
~/.ctxmenu/tmp/
and only in interactive R session and after
the user agrees to do so (unless options(svDialogs.tmpfiles = TRUE)).
Once you installed these files, you can access the menus by setting up
keyboard shortcuts to activate main and context menus. The respective
commands are
ctxmenu-main
and
ctxmenu-context
and you can use the preference panel to assign, e.g., <shift-menu> and
<ctrl-menu>, or other keyboard shortcuts to these commands. Once everything
is set up, you should see your menus appearing when a console where R +
svDialogs runs is the active window and you hit these shortcuts. Note
also that you can define custom context menus for other applications too, see
the
README
file in the
ctxmenu
download.
On Mac OS X, these functions are not implemented yet (but see source of the
package for experimental code commented out and try the JGR version for a
first implementation there).
Action is treated as R input (echoed at the command line, parsed and
executed), except if it is "none". In this case, no action is
done when the menu item is selected (merely as a placeholder for future
menu actions). You can change the action of an existing menu by reissuing
the command with a different action argument.
If the menuname parameter of menuAddItem() does not exists, it is
automatically created. For creating submenus, separate successive menu
names with slashes. Use "-" as name for separation menus under
Windows or Unix/Linux.
Value
These function return NULL invisibly. They are used for their
side-effect of creating, changing, or deleting custom R menus.
## Not run:
## Add a menu and two entries
menuAdd("Test")
menuAddItem("Test", "List objects", "ls()")
menuAddItem("Test", "List search paths", "search()")
## Add a submenu implicitly
menuAddItem("Test/Submenu", "Current working dir", "setwd()")
## Remove Test menu and submenus
menuDel("Test")
## End(Not run)