Re: [OpenMap Users] mouse modes

From: Maria Harmening <maria.harmening_at_greenfieldeng.com>
Date: Thu, 12 Jan 2006 16:14:15 -0500

howdy,

thank you so much for the help! it worked. i subclassed NavMouseMode,
changed the modeID to "Gestures", and overrode mousePressed.
everything seems to be working! here's the code in mousePressed.

thanks again!

maria

public void mousePressed(MouseEvent evt)
  {
    int mask = InputEvent.BUTTON1_MASK - 1;
    int mods = evt.getModifiers() & mask;
    if (mods == 0)
    {
      evt.getComponent().requestFocus();
      getMouseSupport().fireMapMousePressed(evt);
    }
    else
    {
      super.mousePressed(evt);
    }
  }

> Hi Maria,
> You should subclass AbstractMouseMode or CoordsMouseMode or even
> NavMouseMode. If you use PropertyHandler to create your application
> components then MouseDelegator is already registered in MapBean. You
> don't have to do it manually. Also all mouse modes are automatically
> registered in MouseDelegator. If you add only one mouse mode then it
> will be switched on by default and should receive mouse events.
>
> Navigation doesn't involve layers. Mouse mode only changes projection
in
> MapBean. Navigation mouse mode consumes mouse events, I think.
>
> In your case I would:
> - create subclass of NavMouseMode;
> - change its id to GesturesMouseMode.ID - layers usually listen to
> events from this mouse mode;
> - override mousePressed, mouseReleased and mouseClicked methods;
> - all methods which detects mouse pressing should check whether
right
> mouse button was used. Only then panning, zooming or centering should
be
> done. Navigation mouse mode should consume those events, I think.
> - when left button is clicked it should be passed to layers. See
> behavior of GesturesMouseMode - its implementation is really simple -
it
> does nothing.
> - when mouse is moved it should also be passed to layers. Tooltip
> triggering is done in layers.
>
> Switch on debug to trace mouse messages.
> Best regards,
> Piotr Kaminski
>
> Maria Harmening napisaƂ(a):
> > hello,
> >
> > thanks for the tips. i'm trying to write my own MouseMode class
> > because unfortunately having to double click in some instances and
> > single click in other instances is too confusing for the user. the
> > process has to be quick, efficient, and not confusing.
> >
> > i need the right click navigation mode to work all of the time on
all
> > layers. however, the left click gestures mode is only on those
layers
> > that i choose to display tooltips and such. do you have any
> > suggestions on how i should write my own mouse mode? right now i'm
> > trying to make a class that implements MouseListener that detects
> > whether the left or right button was clicked. the listener is
added to
> > the mapbean. once the detection is made, the method redirects the
> > event to the appropriate MapMouseMode method. This isn't working
for
> > me.
> >
> > thanks in advance,
> > maria
> >
> >
> >>Hi Maria,
> >>
> >>If you wish to just switch between mouse modes you have to:
> >> - extends GesturesMouseMode, detect right-click and call method
> >>MouseDelegator.setActiveMouseModeWithID(NavigationMouseMode.ID)
> >> - do similar thing with NavMouseMode: detect left-click and call
> >>MouseDelegator.
> >>
> >>It should work like this: first click changes mouse mode,
subsequent
> >>clicks are interpreted by new mouse mode.
> >>
> >>If you wish to have both Gestures and Navigation functionality in
one
> >>mouse mode (no switching), than you have to write your own
MouseMode
> >>class (possibly extending one of standard mouse modes) and
implement
> >>your logic. The problem is that standard layers respond to mouse
> >
> > modes
> >
> >>of specific IDs. You cannot assign two different IDs to one mouse
> >
> > mode.
> >
> >>So you have to change Layer.getMouseModeServiceList method in each
> >
> > layer
> >
> >>you are going to use with your new mouse mode.
> >>
> >>Hope this helps a little,
> >>Regards,
> >>Piotr Kaminski
> >>
> >>Maria Harmening napisał(a):
> >>
> >>>hello, all,
> >>>
> >>>can anyone tell me if it's possible to set the MapMouseMode
> >>>to "Gestures" if the user left-clicks and "Navigation" if the user
> >>>right-clicks"?
> >>>
> >>>thanks,
> >>>maria
> >>>
> >>>--
> >>>[To unsubscribe to this list send an email to "majdart_at_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_at_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_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
openmap-users"]
>
>

-- 
NeoMail - http://neomail.sourceforge.net
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Jan 12 2006 - 16:20:44 EST

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