ContextMenu[CurrentContext][EntryGenerators] - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Context-Sensitive Menus : CurrentContext : EntryGenerators : ContextMenu/CurrentContext/EntryGenerators/Add

ContextMenu[CurrentContext][EntryGenerators]

  

Add

  

add entry generator to EntryGenerators table for use within context menu module

 

Calling Sequence

Parameters

Description

Examples of EntryGenerators[Add]

Calling Sequence

EntryGenerators[Add](Name, Generator)

Parameters

Name

-

string; index of generator in 'EntryGenerators' table

Generator

-

list of lists or procedure that returns a list of lists; specifies the names that appear as subentries and the values returned when subentries are selected

Description

• 

The EntryGenerators[Add] command adds an entry generator to the context menu module.  Entry generators can be used by entries to dynamically generate subentries to obtain extra information from the user.

• 

The Generator parameter is a list of lists or a procedure that returns a list of lists.  If it is a procedure, then the right-clicked object is passed to the procedure.

  

The list of lists is structured as follows.  Each operand in the outer list is a list, containing a string (the name of the subentry) followed by a list containing information to return to the entry as %ARG1, %ARG2, ...

  

For example, if Generator were [ ["Subentry 1", [1]], ["Subentry 2", [2]], ["Subentry 3", [3]] ] then "Subentry 1", "Subentry 2", and "Subentry 3" are displayed in the context menu.  If "Subentry 2" is selected, then 2 is returned as %ARG1 to the entry.

• 

The Name parameter is the index of the generator in the 'EntryGenerators' table.

Examples of EntryGenerators[Add]

with(ContextMenu[CurrentContext]):

  

Add an entry generator that allows the user to select a desired number of digits for approximation.

EntryGenerators[Add](
  "NumDigits",
  [["5", [5]],
   ["10", [10]],
   ["20", [20]],
   ["50", [50]],
   ["100", [100]]]);

  

Add an entry generator that allows the user to specify the direction and amount of rotation, for example, when rotating the elements of a list.

EntryGenerators[Add](
  "Rotation",
  [["2 to the left", [-2]],
   ["1 to the left", [-1]],
   ["1 to the right", [1]],
   ["2 to the right", [2]]]);

  

Add an entry generator that allows the user to select one of the variables that appears in the right-clicked expression.  For example, this entry generator allows the user to select a variable with respect to which differentiation occurs or to specify the independent variable for a plot.

EntryGenerators[Add](
  "Variables",
  proc()
    local vars;
    try
      vars := Queries[Run]("Variables");
      [seq(
        [sprintf("%a", op(i, values)), [op(i, values)]],
        i=1..nops(values))];
    catch:
    end try;
  end proc);

  

Add an entry generator that allows the user to select an ordered pair of the variables that appear in the right-clicked expression.

EntryGenerators[Add](
  "Variables 2",
  proc()
    local vars, subentries;
    vars := Queries[Run]("Variables");
    subentries := combinat[choose](vars, 2);
    [seq(
      [sprintf("%a, %a", op(op(i, subentries))), op(i, subentries)],
      i=1..nops(subentries))];
  end proc);

See Also

ContextMenu

ContextMenu[CurrentContext][EntryGenerators]

EntryGenerators/Get

EntryGenerators/List

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam