GUI enabling/disabling of controls: Difference between revisions

Content added Content deleted
Line 1:
{{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
dynamically enable and disable GUI components, to give some guidance to the
Line 5 ⟶ 21:
of the application.
 
The task: Similar to the task [[GUI component interaction]] write a program that
that presents a form with three components to the user: A numeric input field
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 user may manually enter a new value into the field,
the field, increment its value with the "increment" button, or decrement the
increment its value with the "decrementincrement" button.,
or decrement the value with the "decrement" button.
 
The input field should be enabled only when its value is zero. The "increment"
The "increment" button only as long as the field's value is less then 10: When the value 10 is
When the value 10 is reached, the button should go into a disabled state. Analogously, the
Analogously, the "decrement" button should be enabled only as long as the value is greater than
the value is greater than zero.
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
but the buttons should reflect that and enable/disable accordingly.
 
=={{header|Ada}}==
Line 283 ⟶ 300:
SYS "SetDlgItemInt", !form%, 101, number% - 1, 1
ENDPROC</lang>
{{out}}
Output:
<p>
[[File:Guienabbc.gif]]
Line 1,489 ⟶ 1,506:
 
=={{header|Scala}}==
[[Category:Scala Implementations]]
<lang Scala>import swing.{ BoxPanel, Button, GridPanel, Orientation, Swing, TextField }
import swing.event.{ ButtonClicked, Key, KeyPressed, KeyTyped }
Line 1,598 ⟶ 1,614:
updateEnables; # Force initial state of buttons</lang>
 
 
{{omit from|PARI/GP}}
{{omit from|Retro}}
 
=={{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.
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.)
by a "spinner" or "up-down" control, not by buttons.)
 
<lang vb>VERSION 5.00
Line 1,677 ⟶ 1,695:
End Select
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}}