SimpleButtonMorph
Last updated at 4:35 pm UTC on 16 January 2006
A SimpleButtonMorph sends a message to a target object when pressed.
An example (put it into a Workspace, select it, and 'do-it'):
s := SimpleButtonMorph new.
s target: World.
s label: 'prev'.
s position: 20 @ (Display height - 40).
s actionSelector: #goBack.
s openInWorld.
This creates a 'go-to-previous-project' button. It may be handy to move it into a parts-bin for easy access and copying in other projects.
A button which jumps to a project labeled 'Examples':
- Copy the code below
- paste it into a Workspace
- select it
- and do-it
- get the halos of the button
- move the button where you want it to be positioned
- you may later choose 'resist drag' and/or 'resist removal' from the Morph's menu.
s := SimpleButtonMorph new.
s target: (Project named: 'Examples').
s label: 'go to Examples'.
s actionSelector: #enter.
s position: 100 @ Display height - 50.
s openInWorld.
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.
For other application examples see: