SetActive - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DocumentTools[Canvas][Script]

  

SetActive

  

set which canvas element is active

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

SetActive(script,Id)

Parameters

script

-

DocumentTools:-Canvas:-Script object

Id

-

canvas element, string, or (group,row) pair

Description

• 

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.

Examples

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

withDocumentTools:-Canvas:

create a canvas with a title, two column headers, and two math expressions

cvNewCanvasSample Canvas,Column 1,Column 2,x,y:

ShowCanvascv

scScript:

get just the math, and note the id if the first element

dataGetMath:

data1:-id

By setting the first element active, we can perform operations relative to this expression, such as adding an annotation

SetActivesc,data1

Annotatesc,the first math element

SetActivesc,data2

Annotatesc,the second math element

Let's go back and extract all of the elements, including the text fields

dataGetMathkeeptext=true:

Note the id starts at "0:0"

data1:-id

SetActivesc,data1

SetTextsc,Change the Title

SetActivesc,data1

SetMathsc,z,where=below

Compatibility

• 

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