[Q] handling mouse events (many questions)

Martin Drautzburg martin.drautzburg at web.de
Thu Apr 18 18:28:06 UTC 2002


Here is what I believe to understand about mouse events. I someone
could comment this and answer the remaining queastions I'd be most
grateful. If you can give me a good pointer, don't read any further. 

Why event handlers ?

	There are event handlers and you can tell them things like

	on: #event send:#selector to: #someObject

	you can also send this to a Morph, but it will implicitly
	create an EventHandler if there isn't one already. I believe
	the benefits of event handlers is that these are objects so
	you can pass them around, but I'm not sure.

When not to use the event handler ?

	However there are also individual methods for #mouseDown: in
	Morph. These seem to get the event first and by default pass
	it to the event handler.

	The individual #mouseDown functions are called from a group of
	functions like #handleMouseDown (in the event-processing
	category). These do some more magic (like informing submorphs
	and marking the event as handled) prior to calling the
	#mouseDown function.

	So the control flow is

	#handleFooEvent: -> #FooEvent: -> eventHandler

	or
	#handleFooEvent: -> #FooEvent:

	if #FooEvent handles the event itself (overriding the
	default).

        I don't understand why there are these methods AND an event
        handler and when to override the methods and when to use the
        event handler.

Double clicks

	Then there is this strange waitForClicksOrDrag: method of
	*Hand* (not morph). I assume the default behaviour is mostly
	what you want. In any case on: #doubleClick and on: #startDrag
	work just fine without any further ado.

        However a #doubleClick is always preceeded by a #click. What
        would I have to do when I want a #doubleClick without a
        #click. 

Drag/Drop

        The only possiblity I found to handle a drop was to override 
        acceptDroppingMorph: aMorph event: anEvent
        This is not done by the event handler. So why do I do this
        with a method whereas for other events I use the event handler
        ? Most notably the TrashCanMorph does not use an event handler
        at all.

List if events
        How do I know what events exist, i.e. what I can pass to the
        #on:send:to.



More information about the Squeak-dev mailing list