DocumentTools[Canvas][Script]
SetState
set hidden canvas state
Calling Sequence
Parameters
Description
Examples
Compatibility
SetState(script,value)
script
-
DocumentTools:-Canvas:-Script object
value
expression, string, or other value
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.
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.
with⁡DocumentTools:-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:
cv≔NewCanvas⁡Counter,Math⁡0,custom=Input,ScriptButton⁡Press,Press,ScriptButton⁡Show Count,Show,State⁡100:
ShowCanvas⁡cv
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
Download Help Document