Greying out buttons
When you create buttons, they are active by default. You can set the state of buttons (sensitive or not sensitive) using the method setSensitive: or sensitive:. If the argument is true, then the button will be active. If the argument is false, then the button will be deactivated (greyed out).
You can query the state of a button by sending it the message sensitive.
Note that any button can be deactivated, including menu buttons.
The following example creates two buttons, then deactivates one of them. You can execute this example in a Workspace or the Transcript.
| shell button1 button2 rowColumn |
shell := CwTopLevelShell
createApplicationShell: 'Shell'
argBlock: nil.
rowColumn := shell
createRowColumn: 'buttons'
argBlock: nil.
rowColumn manageChild.
button1 := rowColumn
createPushButton: 'One'
argBlock: nil.
button1 manageChild.
button2 := rowColumn
createPushButton: 'Two'
argBlock: nil.
button2 manageChild.
shell realizeWidget.
button2 sensitive: false.
Last modified date: 01/29/2015