Mouse Event Handlers
Mouse Event Registration
This page describes how Lively 2 handles mouse events. There are two ways of dealing with events, depending on whether there is a standard morphic behavior that all morphs should implement or not.
Morph>>registerForMouseEvents registers event handlers on a morph. The naming scheme for event handling methods on Morph objects follows the JavaScript name of the event. For example, a method named 'onMouseOver' handles 'onMouseOver' events. Therefore, if you want to implement custom behavior for an event type on Morph m, simply override that method for m, e. g. by adding a new onMouseOver method in the Object Editor. However, some events are handled by methods that end in -'Entry', e. g. 'onMouseDownEntry' (see section 'Morphic Default Behavior'). If you want your Morph to react to these events, name the handler method after the JavaScript event name ('onMouseDown' in this case). Mouse event handler methods take a Morphic event as their first parameter.
Mouse Event Properties
[TODO: describe properties, methods (getPosition etc.) and patchEvent]
Morphic Default Behavior
In order to provide both a consistent experience for end users and a simple programming interface, Morphic in Lively 2 has default event handlers for certain events. These default handlers create Halos, let you drill down a stack of morphs, allow for grabbing etc. The respective event handlers are methods ending in -'Entry', e. g. 'onMouseDownEntry'. In each of these methods, Lively checks whether a default action needs to be triggered. It then decides whether it passes the incoming event on to a method without the 'Entry' suffix. This means that if you want to react on 'onMouseDown' events, all you need to do is override Morph>>onMouseDown (which does nothing but return false). In rare cases it might be necessary to override the corresponding 'Entry' method. This is generally possible, but not recommended. If you do, you can still have a $super reference passed to the overriden method and call $super(evt) (evt being the incoming event) at some point in that method.