Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
A block as the target of a SimpleButtonMorph
Last updated at 11:13 pm UTC on 29 August 2016
The target of an instance of SimpleButtonMorph may be a Block object.
The method #value is sent to it when the button is pressed.
Then the code in the block is executed.

Examples

    s := SimpleButtonMorph new.
    s target: [TttBoardTest new testSuite]. "– this is a block object"
    s label: 'TttBoardTest'.
    s position: 20 @ (Display height - 60). "– this positions the button"
    s actionSelector: #value. "– this message gets sent to the block
                                when the button is released"
    s openInWorld.


or

    s := SimpleButtonMorph new.
    s target: [(EllipseMorph new extent: 5050; color: Color red) openInHand]. "– this is a block object"
    s label: 'Get a red dot'.
    s actionSelector: #value. "– this message gets sent to the block
                                when the button is released"
    s openInHand.

This works in Squeak 5.1 and Pharo 5.0 (and earlier versions)