Re: [OpenMap Users] Mouse clicks with OMGraphicHandlerPlugIn

From: Don Dietrick <>
Date: Thu, 2 Sep 2004 18:40:37 -0400

Hi Andrew,

OMGraphicHandlerLayer does all this automatically.

First, you have to set which mouse modes your layer should listen to.
This can be done in the properties by setting the 'mouseModes' property
to the MapMouseMode ID. Programmatically, you would call
setMouseModeIDsForEvents(String []) on the layer.

For mouse movement events, the mouse event mechanism will call your
layer's isHighlightable(OMGraphic) method. By default, this is true,
but you can override it so that the layer doesn't react to mouse
movement. When this method returns true, three other methods get

getToolTipTextFor(OMGraphic) - return tool tip text, null for nothing

getInfoText(OMGraphic) - return anything you want put in the
InformationDelegator line, null for nothing (default).

highlight(OMGraphic) - change the appearance if you want, or do
nothing. By default, changes line color to select color.

unhighlight(OMGraphic) gets called when the mouse is no longer over
that OMGraphic.

For clicks, the isSelectable(OMGraphic) method gets called, and this
returns false by default. Returning true will cause the
select(OMGraphicList) method to be called, with that OMGraphic on that
list. deselect(OMGraphicList) gets called when something else has been
clicked on. getItemsForOMGraphicMenu(OMGraphic) gets called if the
right mouse button is being used for the click, and returning a List of
MenuItems will cause a pop-up to appear over the map.

if you return true to receivesMapEvents(), the layer will be called
with mouseOver(MapMouseEvent) and leftClick(MapMouseEvent) events not
occuring over any OMGraphics, and getItemsForMapMenu(MapMouseEvent) for
right clicks.

Javadocs for the layer have more information. Also, MapMouseEvents let
you ask them for the lat/lon directly.

- Don

On Sep 2, 2004, at 4:58 PM, Andrew Hnatiw wrote:

> After writing a bunch of stuff into a subclass of
> OMGraphicHandlerPlugIn, I have decided that I need to handle mouse
> events to see if clicks occur on my graphics.  It seems like
> OMGraphicHandlerLayer is the thing to use to do this.  
> If I decide to stick with the plugin, Is there any easy way to use a
> built-in plugin method to tell me which graphics the click occurred
> in, or do I have to manually iterate through the graphics and call
> their contains(int x, int y) methods?  I'm assuming contains is
> already implemented for me... though I don't see how the graphics
> would have access to the projection to figure out if that screen pt is
> actually within them, and it doesn't look like any classes like
> OMCircle actually implement contains().
> Any advice before I get rid of my plugin and move all my code into an
> OMGraphicHandlerLayer?
> Thanks,
> Andrew Hnatiw
> Software Engineer

Don Dietrick,
BBN Technologies, Cambridge, MA

[To unsubscribe to this list send an email to ""
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Sep 02 2004 - 18:42:47 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:05 EDT