GUI enabling/disabling of controls: Difference between revisions

Content added Content deleted
Line 1: Line 1:
{{task|GUI}}{{requires|Graphics}}
{{task|GUI}} {{requires|Graphics}}
{{omit from|ACL2}}
{{omit from|Applesoft BASIC|no concept of a GUI}}
{{omit from|AWK|no concept of a GUI}}
{{omit from|Batch File}}
{{omit from|Blast}}
{{omit from|Brainf***}}
{{omit from|GUISS|Can only do what the installed applications can do}}
{{omit from|Integer BASIC|no concept of a GUI}}
{{omit from|Lilypond}}
{{omit from|Logtalk}}
{{omit from|Lotus 123}}
{{omit from|Maxima}}
{{omit from|PARI/GP}}
{{omit from|PostScript}}
{{omit from|Retro}}

In addition to fundamental [[GUI component interaction]], an application should
In addition to fundamental [[GUI component interaction]], an application should
dynamically enable and disable GUI components, to give some guidance to the
dynamically enable and disable GUI components, to give some guidance to the
Line 5: Line 21:
of the application.
of the application.


The task: Similar to the task [[GUI component interaction]] write a program that
The task: Similar to the task [[GUI component interaction]] write a program
presents a form with three components to the user: A numeric input field
that presents a form with three components to the user:
("Value") and two buttons ("increment" and "decrement").
A numeric input field ("Value") and two buttons ("increment" and "decrement").


The field is initialized to zero. The user may manually enter a new value into
The field is initialized to zero.
The user may manually enter a new value into the field,
the field, increment its value with the "increment" button, or decrement the
value with the "decrement" button.
increment its value with the "increment" button,
or decrement the value with the "decrement" button.


The input field should be enabled only when its value is zero. The "increment"
The input field should be enabled only when its value is zero.
button only as long as the field's value is less then 10: When the value 10 is
The "increment" button only as long as the field's value is less then 10:
reached, the button should go into a disabled state. Analogously, the
When the value 10 is reached, the button should go into a disabled state.
"decrement" button should be enabled only as long as the value is greater than
Analogously, the "decrement" button should be enabled only as long as
the value is greater than zero.
zero.


Effectively, the user can now either increment up to 10, or down to zero.
Effectively, the user can now either increment up to 10, or down to zero.
Manually entering values outside that range is still legal, but the buttons
Manually entering values outside that range is still legal,
should reflect that and enable/disable accordingly.
but the buttons should reflect that and enable/disable accordingly.


=={{header|Ada}}==
=={{header|Ada}}==
Line 283: Line 300:
SYS "SetDlgItemInt", !form%, 101, number% - 1, 1
SYS "SetDlgItemInt", !form%, 101, number% - 1, 1
ENDPROC</lang>
ENDPROC</lang>
{{out}}
Output:
<p>
<p>
[[File:Guienabbc.gif]]
[[File:Guienabbc.gif]]
Line 1,489: Line 1,506:


=={{header|Scala}}==
=={{header|Scala}}==
[[Category:Scala Implementations]]
<lang Scala>import swing.{ BoxPanel, Button, GridPanel, Orientation, Swing, TextField }
<lang Scala>import swing.{ BoxPanel, Button, GridPanel, Orientation, Swing, TextField }
import swing.event.{ ButtonClicked, Key, KeyPressed, KeyTyped }
import swing.event.{ ButtonClicked, Key, KeyPressed, KeyTyped }
Line 1,598: Line 1,614:
updateEnables; # Force initial state of buttons</lang>
updateEnables; # Force initial state of buttons</lang>



{{omit from|PARI/GP}}
{{omit from|Retro}}


=={{header|Visual Basic}}==
=={{header|Visual Basic}}==
In VB, windows are usually created in the IDE. The generated code is hidden from the user unless viewed outside of VB. For the sake of this task, I have included that code.
In VB, windows are usually created in the IDE.
The generated code is hidden from the user unless viewed outside of VB.
For the sake of this task, I have included that code.


(Also, this sort of task would typically be performed by a "spinner" or "up-down" control, not by buttons.)
(Also, this sort of task would typically be performed
by a "spinner" or "up-down" control, not by buttons.)


<lang vb>VERSION 5.00
<lang vb>VERSION 5.00
Line 1,677: Line 1,695:
End Select
End Select
End Sub</lang>
End Sub</lang>

{{omit from|ACL2}}
{{omit from|Applesoft BASIC|no concept of a GUI}}
{{omit from|AWK|no concept of a GUI}}
{{omit from|Batch File}}
{{omit from|Blast}}
{{omit from|Brainf***}}
{{omit from|GUISS|Can only do what the installed applications can do}}
{{omit from|Integer BASIC|no concept of a GUI}}
{{omit from|Lilypond}}
{{omit from|Logtalk}}
{{omit from|Lotus 123}}
{{omit from|Maxima}}
{{omit from|PostScript}}