GUI enabling/disabling of controls: Difference between revisions

Content added Content deleted
No edit summary
Line 1,420: Line 1,420:


n.b. Open stack handlers would be prudent to initialise the default value and button states if this were to be saved for standalone execution.
n.b. Open stack handlers would be prudent to initialise the default value and button states if this were to be saved for standalone execution.

=={{header|Maple}}==
For this problem, you will need to open up Maple, go to the Components tab on the left, and insert a Text Area, and 2 Buttons. By right clicking each button, and clicking Component Properties, change one to Increase, and the other to Decrease. Then, click on 'Edit Content Changed Action". In the one labeled increase, type:

<lang Maple>
Increase();
</lang>

In the one labeled Decrease, type:

<lang Maple>
Decrease();
</lang>

Then, by clicking the 2 gears and opening up the start-up commands, enter this:
<lang Maple>
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty);
with(Maplets[Elements]):
SP("Text",value,0);
Increase:=proc()
SP("Text",value,parse(GP("Text",value))+1);
if parse(GP("Text",value))>=10 then
SP("Button0", enabled, false);
else
SP("Button0", enabled, true);
end if;
if parse(GP("Text",value))<=0 then
SP("Button1", enabled, false);
else
SP("Button1", enabled, true);
end if;
end proc;
Decrease:=proc()
SP("Text",value,parse(GP("Text",value))-1);
if parse(GP("Text",value))<=0 then
SP("Button1", enabled, false);
else
SP("Button1", enabled, true);
end if;
if parse(GP("Text",value))>=10 then
SP("Button0", enabled, false);
else
SP("Button0", enabled, true);
end if;
end proc;
</lang>


=={{header|Mathematica}}==
=={{header|Mathematica}}==