ModuleContextMenu - Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : ModuleContextMenu

ModuleContextMenu

procedure that specifies context menu entries for a module

 

Calling Sequence

Description

Examples

Calling Sequence

module() export ModuleContextMenu, ...; ... end module;

module() local ModuleContextMenu, ...; ... end module;

Description

• 

If a module m has an export or local named ModuleContextMenu, the result of the m[ModuleContextMenu](m) command is used to generate context menu entries in the context menu for m.

• 

The value returned by ModuleContextMenu is interpreted as described below. If the value as a whole cannot be correctly interpreted according to these specification, then no extra context menu entries are generated.

• 

A list of two strings represents one context menu entry. The first string is the text as it will appear in the context menu; the second string describes the action Maple takes if that entry is selected. If the name %EXPR occurs in the string, it is replaced by the selected module. The second string is parsed and evaluated as Maple code, in the global name space; there is no lexical scoping access.

  

In addition to these two strings, there can also be optional equations of the form helpstring = string or operator = TypeMK. These have the same function as in ContextMenu/CurrentContext/Entries/Add.

  

An equation of the form helpstring = string specifies the text that the user sees when the mouse cursor is positioned above this entry in a context menu while either using the Classic worksheet, or using the Standard worksheet with menu tips enabled.

  

An equation of the form operator = TypeMK specifies what 2D math transition should appear when working in document mode and performing context menu entries in-line.  The default value for this option is Typesetting:-mo("→") which is displayed as a right arrow . When customizing this it is recommended to use the template Typesetting:-mover(Typesetting:-mo("oper"),Typesetting:-mtext("text")) where oper should be an operator symbol, like → or =, and text should be a text description like transpose.  Most MathML operator symbols are supported as a choice for oper.  For example, setting operator to Typesetting:-mover(Typesetting:-mo("⇒"),Typesetting:-mtext("implies")) displays as implies.

• 

A list where the first entry is a string and the second entry is a list represents a submenu. The string is the text as it will appear in the context menu to indicate the submenu. The elements of the list are interpreted as entries or submenus themselves.

• 

Finally, the return value can be an expression sequence: the elements of that sequence should be lists as described above (either representing individual context menu entries, or representing submenus). The menu entries may be reordered: it is not guaranteed that they appear in the context menu in the order given, or indeed that they appear together.

Examples

Below is an implementation of a point in a 2D lattice.

LatticePoint := proc(x0 :: integer, y0 :: integer, $)
  return module()
    local x := x0, y := y0, ModuleContextMenu;
    export left, right, up, down, toList;

    left := proc($) x := x - 1; end proc;
    right := proc($) x := x + 1; end proc;
    up := proc($) y := y + 1; end proc;
    down := proc($) y := y - 1; end proc;

    toList := proc($) [x, y]; end proc;

    ModuleContextMenu := proc(point)
      return ["Point operations", [["left",  "%EXPR:-left();"],
                                   ["right", "%EXPR:-right();"],
                                   ["up",    "%EXPR:-up();"],
                                   ["down",  "%EXPR:-down();"]]],
             ["Convert to List", "%EXPR:-toList();"];
    end proc;
  end module;
end proc:

We can now create lattice points as follows.

AALatticePoint2,0;AA

AAmodulelocalx,y,ModuleContextMenu;exportleft,right,up,down,toList;end module

AA

(1)

BBLatticePoint1,3;BB

BBmodulelocalx,y,ModuleContextMenu;exportleft,right,up,down,toList;end module

BB

(2)

The context menus of AA and BB contain a submenu with four entries that come from the ModuleContextMenu procedure.

See Also

ContextMenu

module

ModuleApply

ModulePrint

procedure