DocumentTools[Canvas][Script]
SetButton
set a property of a button
Calling Sequence
Parameters
Description
Examples
Compatibility
SetButton(script,caption,property,value)
script
-
DocumentTools:-Canvas:-Script object
caption
string : the caption of the button to operate on
property
string : the name of the property to set
value
the value of the property
The SetButton command sets the specified property of the given button. Unlike math and text containers, the SetActive command is not used as a precursor to this command. Instead, the caption of the button is used to identify the button to change. If there is more than one button with the same caption, only the first found will be updated.
In this example there are four buttons. The first button does not have an action associated with it. The remaining buttons modify properties of the first button.
with⁡DocumentTools:-Canvas:
toggle := proc(canvas,prop,source) local sc := Script(); local me := GetElements(canvas,"button",filter={'name'=source[1]}); if numelems(me) > 0 then SetButton(sc,"Target",prop,true); SetButton(sc,source[1],"caption",source[2]); else SetButton(sc,"Target",prop,false); SetButton(sc,source[2],"caption",source[1]); end if; ToString(sc); end proc:
setprop := proc(canvas,prop,val) local sc := Script(); SetButton(sc,"Target",prop,val); ToString(sc); end proc:
cv≔NewCanvas⁡ScriptButton⁡Target,,ScriptButton⁡Disable,toggle,parameters=enabled,Enable,Disable,ScriptButton⁡Hide,toggle,parameters=visible,Show,Hide,ScriptButton⁡Make Red,setprop,parameters=color,red:
ShowCanvas⁡cv,entrybox=false
The DocumentTools[Canvas][Script][SetButton] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
GetMath
Script
ScriptButton
SetActive
Download Help Document