SetState - 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]

  

SetState

  

set hidden canvas state

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

SetState(script,value)

Parameters

script

-

DocumentTools:-Canvas:-Script object

value

-

expression, string, or other value

Description

• 

The SetState command records a string property that can be fetched by GetElements. This allows you to query and update hidden values in a canvas-based application.

Examples

In this example, the number of times the Press button is pressed is stored behind the scenes, and only revealed when the Show Count button is pressed. The initial state of 100 is given in the constructed canvas by a call to the State command.

withDocumentTools:-Canvas:

Press := proc(canvas)
   local state := GetElements(canvas,"state");
   local sc := Script();
   SetState(sc,1+state[1]:-value);
   ToString(sc);
end proc:

Show := proc(canvas)
   local M := GetElements(canvas,'custom'="Input");
   local state := GetElements(canvas,"state");
   local sc := Script();
   SetActive(sc,M[1]);
   SetMath(sc,state[1]:-value);
   ToString(sc);
end proc:

cvNewCanvasCounter,Math0,custom=Input,ScriptButtonPress,Press,ScriptButtonShow Count,Show,State100:

ShowCanvascv

Compatibility

• 

The DocumentTools[Canvas][Script][SetState] command was introduced in Maple 2022.

• 

For more information on Maple 2022 changes, see Updates in Maple 2022.

See Also

GetMath

Script

SetActive