DocumentTools[Components]
Shortcut
generate XML for a Shortcut Component
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Shortcut( caption, opts )
caption
-
(optional) string:=""; the caption on the component
opts
(optional) ; one or more keyword options as described below
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.
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.
with⁡DocumentTools:
with⁡DocumentTools:-Layout:
with⁡DocumentTools:-Components:
Executing the Shortcut command produces a function call.
S≔Shortcut⁡My Shortcut,identity=Shortcut0
S≔_XML_EC-Shortcut⁡id=Shortcut0,caption=My Shortcut,enabled=true,visible=true
By using commands from the Layout Constructors package a nested function call can be produced which represents a worksheet.
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡S:
That XML representation of a worksheet can be inserted directly.
InsertContent⁡xml:
My Shortcut
S≔Shortcut⁡New Shortcut,identity=Shortcut0,tooltip=my shortcut:
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.
lookup≔InsertContent⁡xml,output=table
lookup≔table⁡Shortcut0=Shortcut1
New Shortcut
lookupShortcut0
Shortcut1
GetProperty⁡lookupShortcut0,caption
The next example generates and inserts a shortcut for launching help on the int command.
L≔Shortcut⁡Help for int,identity=Shortcut17,target=Help:int:
InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡L:
Help for int
The following examples insert components with custom images.
img≔cat⁡kernelopts⁡datadir,/images/antennas.jpg:
L≔Shortcut⁡New Shortcut,identity=Shortcut17,image=img,width=120,height=120:
img≔Array⁡1..60,1..40,1..3,i,j,k↦`if`⁡k=3,j40,0,datatype=float8,order=C_order:
L≔Shortcut⁡New Shortcut,identity=Shortcut17,image=img:
L≔Shortcut⁡New Shortcut,identity=Shortcut17,image=img,width=70,height=20:
The DocumentTools:-Components:-Shortcut command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
Component Code
Component Constructors
DocumentTools
Embedded Components
XMLTools
Download Help Document