Programmer's Reference

Push-button widgets

Create push-button widgets (CwPushButton) using the createPushButton:argBlock: convenience method.
Push button widget

Push buttons call their activate callback when they are pressed and released.

In the following example, three buttons are created in a row-column. An activate callback has been added to each button. The same callback message is used in all three cases. The client data of the callback is used to identify which button was pressed. For simplicity, the shell is not shown in the diagram.

| shell rowColumn row b1 b2 b3 |
shell := CwTopLevelShell
   createApplicationShell: 'Test'
   argBlock: nil.
 
rowColumn := shell
   createRowColumn: 'buttons'
   argBlock: nil.
rowColumn manageChild.

Row column

b1 := rowColumn
   createPushButton: 'Top'
   argBlock: nil.
b1
   addCallback: XmNactivateCallback
   receiver: self
   selector: #button:clientData:callData:
   clientData: 'top'.
b1 manageChild.
b2 := rowColumn
   createPushButton: 'Middle'
   argBlock: nil.
b2
   addCallback: XmNactivateCallback
   receiver: self
   selector: #button:clientData:callData:
   clientData: 'middle'.
b2 manageChild.
b3 := rowColumn
  createPushButton: 'Bottom'
  argBlock: nil.
b3
   addCallback: XmNactivateCallback
   receiver: self
   selector: #button:clientData:callData:
   clientData: 'bottom'.
b3 manageChild.
shell realizeWidget.

Here is the activate callback used in the code:

button: widget clientData: clientData callData: callData
"A button has been pressed."
   Transcript cr; show: 'The ', clientData, ' button has been pressed.'


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]