DocumentTools[Canvas][Script]
SetActive
set which canvas element is active
Calling Sequence
Parameters
Description
Examples
Compatibility
SetActive(script,Id)
script
-
DocumentTools:-Canvas:-Script object
Id
canvas element, string, or (group,row) pair
The SetActive command specifies which component of a canvas is active. Further script operations can operate relative to the active element, such as changing the math, or adding new components beside or below.
A "canvas" is an interactive section of a Maple document created by the NewCanvas command, or a shared web-based Maple Learn document. See the Script command for a more complete description.
The Id argument can be an element containing an id, as per the returned elements from GetMath, or it can be the id itself as a string, or (group,row) pair. The first math or text component on a canvas has the id "0:0". The second math or text component measured left-right, then top-down on the canvas has the id "1:0" unless it is in the same group as the first, in which case it will have id "0:1". Only elements of a group can have nonzero after the colon.
Be careful when using a literal id to reference an element from a canvas fetched by the GetCanvas command. A Maple Learn document that a user has modified can have new groups anywhere and the id order may not match the template order of the components prior to insertion of those groups. In these cases it is best to use the element returned by the GetMath command when applying scripts.
In this example, we will insert a canvas, get the math from the canvas, then make various elements active so that operations can be performed
with⁡DocumentTools:-Canvas:
create a canvas with a title, two column headers, and two math expressions
cv≔NewCanvas⁡Sample Canvas,Column 1,Column 2,x,y:
ShowCanvas⁡cv
sc≔Script⁡:
get just the math, and note the id if the first element
data≔GetMath⁡:
data1:-id
By setting the first element active, we can perform operations relative to this expression, such as adding an annotation
SetActive⁡sc,data1
Annotate⁡sc,the first math element
SetActive⁡sc,data2
Annotate⁡sc,the second math element
Let's go back and extract all of the elements, including the text fields
data≔GetMath⁡keeptext=true:
Note the id starts at "0:0"
SetText⁡sc,Change the Title
SetActive⁡sc,data−1
SetMath⁡sc,z,where=below
The DocumentTools[Canvas][Script][SetActive] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
Annotate
GetMath
Script
Download Help Document