MiG InfoCom MiG Calendar AShape Developer Manual User Manual
Page 23

MiG InfoCom AB
Events
Interactor
s are the objects responsible for dispatching and
processing
InputEvent
s. This is normally done by the
MouseKeyInteractor
with a
DefaultInteractionBroker
as the receiver of the
Command
s run when an
Interaction
should occur.
How does the
MouseKeyInteractor
get the events? The
simple fact is that it doesn't. The
Container
in which the
AShape
is to be painted (for instance the
AShapeComponent
as explained above) has to provide them
to the
Interactor
s.
This could be done automatically by the
Interactor
but it
would break some applications that also listens on the
Event
s very early in the dispatching process so this way is
more compatible, but you will have to remember to do it if
you provide your own
Component
container. Here is the code
from
AShapeComponent
that forwards the
InputEvent
s to
the
Interactor
s of the
AShape
. Note that all
Interactor
s of all decorated entities must be notified. This
method will override the
processEvent()
of the
Component
class to first re-dispatch them to the
Interactor
s.
/** Overridden to let all activity views have fist chance to interact with the events
and
* if they are consumed disregard them for further processing.
* @param e The event.
*/
protected void processEvent(AWTEvent e)
{
if (e instanceof InputEvent) {
Interactor[] interactors = rootShape.getInteractors();
if (interactors != null) {
InputEvent ie = (InputEvent) e;
for (int i = 0; i < interactors.length; i++)
interactors[i].processEvent(ie);
if (ie.isConsumed())
return;
// Resets the Cursor. Only needed if the AShape changes it in the first place
if (e instanceof MouseEvent) {
if((MouseEvent) e).getID() == MouseEvent.MOUSE_ENTERED)
setCursor(null); // Whatever cursor that is to be used
}
}
}
super.processEvent(e);
}
AShape Developer Manual
Page 23 / 24