IconicButton and Events

Ned Konz ned at bike-nomad.com
Mon Apr 15 20:05:58 UTC 2002


On Monday 15 April 2002 12:35 pm, Stef Telford wrote:
> and there could be a lot of buttons, it doesnt really
> make much sense to subclass all 20 buttons, each with
> what is potentially a minor difference. Current code
> goes something like this:
>
>         s:=GradientFillMorph new.
>                 s addMorphCentered: (a:=IconicButton new).
>                 a on: #mouseDown send: #value to:[Transcript
> show:'you clicked']. s openInWorld.
>
>         Okay, barring the fact that its not the worlds
> most awe inspiring nor amazing piece of code (the variables
> are mainly there as its being tested in a workspace), is that
> the 'cleanest' way to add an event into an Instance of
> a pre-defined Morph at 'creation' time ?

Maybe I'm missing something, but haven't you already answered your own 
question?

You can plug the response of these buttons using

target:
arguments:
actionSelector:

So your example could be:

  s:=GradientFillMorph new.
                s addMorphCentered: (IconicButton new
target: Transcript;
actionSelector: #show: ;
arguments: { 'you clicked' } ).
        s openInWorld.


-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list