Hi Brian,
On Mar 23, 2004, at 9:08 AM, Sperlongano Brian M NPRI wrote:
> I'm trying to make my layer receive mouse events.
OK.
>
> In addition, I'm trying to make the MapBean receive mouse events
> (click to recenter, mouse wheel to zoom).
The MapBean is set up to receive ZoomEvents and CenterEvents, so is
usually handled by a MapMouseMode that interprets the MouseEvents to
tell the MapBean want to do. The NavMouseMode (and NavMouseMode2)
already click to recenter, you can extend them to handle mouse wheel
events.
> Now, I made my layer implement MapMouseListener, and overrided the
> getMouseModeServiceList() function as follows:
>
> public String[] getMouseModeServiceList()
> {
> return new String[] { SelectMouseMode.modeID };
> }
This looks good for the layer.
> On my overridden MapBean class, I implement MouseListener and
> MouseWheelListener.
I'd make the NavMouseModes the MouseWheelListener. Then you can add
your version to the openmap.components property of the
openmap.properties file instead.
> My problem is that while the MapBean gets all the mouse events, the
> Layer doesn't seem to get any. I suspect the
> MouseListener/MouseWheelListener is blocking the layer from getting
> mouse events. Any thoughts?
By adding the MapBean as a listener to itself, you're probably stomping
on the mechanism that gets the layer their events.
> --- on a related note ---
>
> When going through the documentation on MapMouseListener, I found the
> following paragraph in the description for the method
> getMouseModeServiceList():
>
> "Return a list of the modes that are interesting to the
> MapMouseListener. The source MouseEvents will only get sent to the
> MapMouseListener if the mode is set to one that the listener is
> interested in. Layers interested in receiving events should register
> for receiving events in "select" mode"
>
> What the heck does this paragraph mean?
There's a notion in OpenMap where mouse events are handled by Modes,
which dictate behavior of the application by funneling the MapBean
mouse events to those components participating in the current behavior.
The 'select' mode is governed by the SelectMouseMode, and you can have
your mml get events from it by returning it's ID in the
getMouseModeServiceList() method, as you have. If you have a different
MouseMode with a different ID, you could receive events from that mode,
too, by adding that ID to the array returned by that method.
Hope this helps,
- Don
>
>
> Thanks,
> Brian
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Tue Mar 23 10:14:47 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT