menu: Manage custom R menus.

menuR Documentation

Manage custom R menus.

Description

Create, populate and rework custom R menus.

Usage

menu_names()

menuNames()

menu_items(menuname)

menuItems(menuname)

menu_add(menuname)

menuAdd(menuname)

menu_add_item(menuname, itemname, action)

menuAddItem(menuname, itemname, action)

menu_del(menuname)

menuDel(menuname)

menu_del_item(menuname, itemname)

menuDelItem(menuname, itemname)

Arguments

menuname

A character string naming a menu.

itemname

A character string naming a menu item on an existing menu.

action

A character string with the action to perform when the menu item is selected, or "none" for no action. Use "enable" or "disable" to activate or deactivate 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 the menu actions. You can download corresponding files (GPL-2 license) and get further instructions at the bottom of http://www.sciviews.org/SciViews-R/. The R code in 'svDialogs' 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 (after you have defined at least one custom menu). Note also that you can define custom context menus for other applications too, see the README file in the ctxmenu download.

On MacOS, 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 run 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 menu_add_item() 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.

See Also

dlg_open(), dlg_save()

Examples

## Not run: 
# A quick default directory changer
setwd(dlg_dir(default = getwd())$res)

## End(Not run)

svDialogs documentation built on May 10, 2022, 9:06 a.m.