Q: How to create a command button

Hannes Hirzel hirzel at spw.unizh.ch
Thu Mar 14 08:32:50 UTC 2002


On 14 Mar 2002, Martin Drautzburg wrote:

> What is the easiest way to create a button, that evaluates a smalltalk
> expression. 
> 
> I am currenly writing my first lines of Smalltalk code (a TestCase)
> and I need to run this every minute. I would like to have a button
> that evals [TttBoardTest new testSuite]. Tried some of the morphic
> Buttons but all I could make them do was flash.
> 

I don't know if it is the easiest way but at least it is easy:

 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; it causes
                                  the block to evaluate its expressions."
 s openInWorld.

(I just put this example on
http://minnow.cc.gatech.edu/squeak/SimpleButtonMorph ; there are some more
examples)

Regards
Hannes Hirzel






More information about the Squeak-dev mailing list