Shortcut Component - Maple Help

DocumentTools[Components]

 Shortcut
 generate XML for a Shortcut Component

 Calling Sequence Shortcut( caption, opts )

Parameters

 caption - (optional) string:=""; the caption on the component opts - (optional) ; one or more keyword options as described below

Options

 • enabled : truefalse; Indicates whether the component is enabled. The default is true. If enabled is false then the inserted component is grayed out and interaction with it cannot be initiated.
 • height : posint; The height in pixels of the component.
 • identity : {name,string}; The reference name of the component.
 • image : {string,Matrix,Array}; Image to be displayed on the component, specified as either the name of an external image file or a Matrix or Array as recognized by commands in the ImageTools package. The caption parameter and the image option are mutually exclusive; only one can be supplied.
 • target : string; A string denotes the link target. See the section Valid Link Targets on the Shortcut Component help page for a table of allowed targets. The default is the empty string (no target prespecified).
 • tooltip : string; The text that appears when the mouse pointer hovers over the component. The default is the empty string (no tooltip).
 • visible : truefalse; Indicates whether the component is visible. The default is true.
 • width : posint; The width in pixels of the component.

Description

 • The Shortcut command in the Component Constructors package returns an XML function call which represents a Shortcut Component.
 • The generated XML can be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document can be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$

Executing the Shortcut command produces a function call.

 > $S≔\mathrm{Shortcut}\left("My Shortcut",\mathrm{identity}="Shortcut0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-Shortcut}}{}\left({"id"}{=}{"Shortcut0"}{,}{"caption"}{=}{"My Shortcut"}{,}{"enabled"}{=}{"true"}{,}{"visible"}{=}{"true"}\right)$ (1)

By using commands from the Layout Constructors package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

My Shortcut

 > $S≔\mathrm{Shortcut}\left("New Shortcut",\mathrm{identity}="Shortcut0",\mathrm{tooltip}="my shortcut"\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

The previous example's call to the InsertContent command inserted a component with identity "Shortcut0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "Shortcut0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"Shortcut0"}{=}{"Shortcut1"}\right]\right)$ (2)

New Shortcut

 > $\mathrm{lookup}\left["Shortcut0"\right]$
 ${"Shortcut1"}$ (3)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["Shortcut0"\right],\mathrm{caption}\right)$
 ${"New Shortcut"}$ (4)

The next example generates and inserts a shortcut for launching help on the int command.

 > $L≔\mathrm{Shortcut}\left("Help for int",\mathrm{identity}="Shortcut17",\mathrm{target}="Help:int"\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(L\right)\right)\right)\right)\right):$

Help for int

The following examples insert components with custom images.

 > $\mathrm{img}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/antennas.jpg"\right):$
 > $L≔\mathrm{Shortcut}\left("New Shortcut",\mathrm{identity}="Shortcut17",\mathrm{image}=\mathrm{img},\mathrm{width}=120,\mathrm{height}=120\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(L\right)\right)\right)\right)\right):$

New Shortcut

 > $\mathrm{img}≔\mathrm{Array}\left(1..60,1..40,1..3,\left(i,j,k\right)↦\mathrm{if}\left(k=3,\frac{j}{40},0\right),\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{order}=\mathrm{C_order}\right):$
 > $L≔\mathrm{Shortcut}\left("New Shortcut",\mathrm{identity}="Shortcut17",\mathrm{image}=\mathrm{img}\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(L\right)\right)\right)\right)\right):$

New Shortcut

 > $L≔\mathrm{Shortcut}\left("New Shortcut",\mathrm{identity}="Shortcut17",\mathrm{image}=\mathrm{img},\mathrm{width}=70,\mathrm{height}=20\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(L\right)\right)\right)\right)\right):$

New Shortcut

Compatibility

 • The DocumentTools:-Components:-Shortcut command was introduced in Maple 2015.