Creating Custom Context Menu Entries - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim

Creating Custom Context Menu Entries


You can customize the entries and actions on a context menu module using the ContextMenu package commands.


Note: On this help page, the custom context menu module is referenced by the name newCM.


Simple Entries

Submenus and Categories

Additional Information

Simple Entries


The simplest context configuration that can be created is a single entry with a command.

newCM:-Entries:-Add( "Increment the integer", "%EXPR + 1", integer );


This command adds a menu entry with the text label Increment the integer to the top-level context menu.


The second argument, %EXPR + 1, is a string that indicates the action to be performed if the associated menu entry is selected. The text %EXPR serves as a placeholder for the object that the user clicks, and will be replaced by the value of this object if the associated entry is selected. For example, if a user selects the Maple integer 5, and selects Increment the integer from the operations listed in Context Panel, the text 5 + 1 is inserted into the worksheet.


The third argument, integer, specifies that this menu entry appears only when the object in focus is of type integer.

Entries with Help Strings


You can optionally supply a help string for a menu entry.  A help string is text, usually slightly longer than the text of the menu entry, that describes the action performed.  It is displayed in a tooltip when the mouse pointer is positioned over the menu entry. For example:

newCM:-Entries:-Add( "Increment the integer", "%EXPR + 1", integer, helpstring="Increment the integer by 1" );

Submenus and Categories


When designing a menu system, it is recommended that you group together entries that are logically related, and impose a hierarchy on menu entries to avoid a single menu with an overwhelming number of entries. These two goals can be accomplished by using submenus and categories.



A submenu is a context menu that is launched by clicking an entry in a context menu. Submenus are useful for grouping together a set of related entries.


When adding an entry to the context menu module, you can specify that this entry be placed in a submenu by using the submenu option.

newCM:-Entries:-Add( "To String", "convert(%EXPR, string)",  Not(string), submenu=["Conversions"] );


The To String entry is placed on the Conversions submenu within the context menu system.  For more information, see ContextMenu[CurrentContext][Entries][Add].



You can group together related entries in the top-level context menu without placing the groupings in separate submenus.  This can be achieved using categories.


When adding an entry to a context menu module, you can specify a category by using a Maple string.  Entries in the top-level context menu that have identical categories are grouped together in the menu. A horizontal divider is drawn between entries of different categories.


Note: The category name is not displayed in the context menu.


Important: Categories can be used only in top-level menu entries, not submenu entries.

newCM:-Entries:-Add( "Factor Integer", "ifactor(%EXPR)", integer, category="Integers" );
newCM:-Entries:-Add( "Test Primality", "isprime(%EXPR)", integer, category="Integers" );
newCM:-Entries:-Add( "Floor",          "floor(%EXPR)",   {float, fraction}, category="Non-Integers" );


The Factor Integer and Test Primality entries are grouped together in the top-level menu, with a dividing line separating them from the Floor entry.

Additional Information


For more information on customizing the context menus, see ContextMenu[CurrentContext].

See Also

Appending Actions to the Context Menu System


ContextMenu Example Worksheet





Creating a Context Menu System

Overview of Creating Context Menus