Action - Maple Help

Maplets[Elements]

 Action
 define an action

 Calling Sequence Action(opts, element_content) Action[refID](opts, element_content)

Parameters

 opts - equation(s) of the form reference=value; specify options for the Action element element_content - any number of Action or command elements refID - name or string; reference to the element

Description

 • The Action element defines an action in a Maplet application.
 • The Action element features can be modified by using options.  To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are, by default, assigned.

 Elements, Symbols, or Types Assumed Option or Content refID reference option

 • An Action element can contain any number of other Action elements or command elements such as CloseWindow, Evaluate, SetOption, RunWindow, RunDialog, and Shutdown.
 • An Action element can be contained in a Maplet element; in an equation for the onapprove, oncancel, onchange, onclick, ondecline, or onstartup option for an element; or as a parameter in an element that accepts an onchange or onclick option without an equation.
 • The contents of an Action element are evaluated in order. Each action is completed before the next is started.  The contents of any nested Action elements are evaluated in order.
 • The following table describes the control and use of the Action element options.
 An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).
 An x in the R column indicates that the option is required in the calling sequence.
 An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.
 An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.

 Option I R G S reference x run x

 • The opts argument can contain one or more of the following equations that set Maplet application options.
 reference = name or string
 A reference for the Action element.
 If the reference is specified by both an index, for example, Action[refID], and a reference in the calling sequence, the index reference takes precedence.
 run = true
 This is a settable field that indicates that the specified action be run as soon as control returns to the Maplet application. This is useful for specifying the conditional shutdown of a window.

Examples

A Maplet application that has actions associated with buttons:

 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet1}≔\mathrm{Maplet}\left(\left[\left[\mathrm{TextField}\left['\mathrm{TF1}'\right]\left(\right)\right],\left[\mathrm{Button}\left['\mathrm{B1}'\right]\left("Clear",'\mathrm{onclick}'='\mathrm{A1}'\right)\right],\left[\mathrm{Button}\left['\mathrm{B2}'\right]\left("OK",'\mathrm{onclick}'='\mathrm{A2}'\right)\right]\right],\mathrm{Action}\left['\mathrm{A1}'\right]\left(\mathrm{SetOption}\left('\mathrm{target}'='\mathrm{TF1}'\right)\right),\mathrm{Action}\left['\mathrm{A2}'\right]\left(\mathrm{Shutdown}\left(\left['\mathrm{TF1}'\right]\right)\right)\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet1}\right)$

Note that this Maplet application can more easily be written as:

 > $\mathrm{maplet2}≔\mathrm{Maplet}\left(\left[\left[\mathrm{TextField}\left['\mathrm{TF1}'\right]\left(\right)\right],\left[\mathrm{Button}\left['\mathrm{B1}'\right]\left("Clear",\mathrm{SetOption}\left('\mathrm{target}'='\mathrm{TF1}'\right)\right)\right],\left[\mathrm{Button}\left['\mathrm{B2}'\right]\left("OK",\mathrm{Shutdown}\left(\left['\mathrm{TF1}'\right]\right)\right)\right]\right]\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet2}\right)$