Recipe: How to use an IconicButton in Morphic
Last updated at 6:55 pm UTC on 1 January 2019
You would like to have an icon in your Morphic world which activates the evaluation of a block of code when clicked.
You might want to use an IconicButton. If the action you want to perform is relatively simple, you don't even have to override anything.
aTarget := "do something when button is clicked" [Transcript show: 'Button Pressed!'; cr].
i := IconicButton new.
"i labelGraphic: aForm."
i target: aTarget.
i actionSelector: #value.
Then select the above text, (Cmd D) DoIt and you'll get a new button. Press the button and the Transcript should print the message.
The "target" in the above will be evaluated (because the actionSelector of #value tells the system to evaluate the block 'aTarget' by using the selector 'value' on it) when you click on the button. You can pass any number of arguments to the target as well.
Source: Mailing list - email@example.com / Fri, 26 Nov 1999
See also IconicButton
TODO: elaborate how to get a different form/ icon to be shown