Custom Event Handler

Ned Konz ned at bike-nomad.com
Tue Aug 7 16:45:27 UTC 2001


On Tuesday 07 August 2001 09:20 am, Josh wrote:

> I'm implementing a drawing app where there are multiple 'tools'
> available, one of which is active at any given time.  Depending on the
> tool selected, mouse actions have different effects.  For example, if
> the 'selection' tool is active, clicking on a morph will toggle
> whether it is selected.  If the 'delete' tool is active, clicking on a
> morph will delete it (and possibly other morphs in its group).
>
> One reason that I care about mouseEnter/Leave is that I want all
> morphs in a group to be highlighted whenever the pointer enters any
> morph in the group.

One possibility is to have the tools do a mouse capture and then handle the 
mouse events themselves, sending various messages to the involved other 
morphs.

So for instance, a mouse click is received by the tool, and translated into a 
toolWhateverClicked: evt call on the appropriate Morph.

For mouse over detection, the tool could just look at which Morphs were below 
the mouse position, and call toolEntered: or toolLeft: or something like this.

That way, you don't have to change the event handling of existing Morphs, and 
get to work with any old Morph.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com




More information about the Squeak-dev mailing list