Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Handling mouse events
Handling mouse events [message #103725] Wed, 14 February 2007 06:20 Go to next message
Eclipse UserFriend
Originally posted by: jiri_semecky.cz.ibm.com

Hi,

I'm trying to handle mouse events on particular subfigures of an EditPart.
I added org.eclipse.draw2d.MouseListener to figures (subclasses of
org.eclipse.draw2d.Figure) in XXXFigure.createContents() method.

However the events are caught only if the EditPart consists of a single
Figure. If the figure is more complex (composed of several subfigures,
e.g. compartments), the events do not get to the figure. They are caught
by an instance of ShapeCompartmentFigure, DefaultSizeNodeFigure,
WrapLabel or so, but they are not propagated to the figure directly
created in createContents().

Please, how can be the mouse event handled for subregions of an
EditPart? The EditPolicy mechanism doesn't work here, because it is only
EditPart-grained (without the information which subfigure was clicked).

Thanks for any hint,
Jirka
Re: Handling mouse events [message #103802 is a reply to message #103725] Wed, 14 February 2007 07:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 5d5.mail.ru

SWTEventDispatcher emits draw2d events; you may try to trace what
happens there...

Jiri Semecky wrote:
> Hi,
>
> I'm trying to handle mouse events on particular subfigures of an EditPart.
> I added org.eclipse.draw2d.MouseListener to figures (subclasses of
> org.eclipse.draw2d.Figure) in XXXFigure.createContents() method.
>
> However the events are caught only if the EditPart consists of a single
> Figure. If the figure is more complex (composed of several subfigures,
> e.g. compartments), the events do not get to the figure. They are caught
> by an instance of ShapeCompartmentFigure, DefaultSizeNodeFigure,
> WrapLabel or so, but they are not propagated to the figure directly
> created in createContents().
>
> Please, how can be the mouse event handled for subregions of an
> EditPart? The EditPolicy mechanism doesn't work here, because it is only
> EditPart-grained (without the information which subfigure was clicked).
>
> Thanks for any hint,
> Jirka
Re: Handling mouse events [message #103930 is a reply to message #103725] Wed, 14 February 2007 09:34 Go to previous message
Eclipse UserFriend
Jirka,

I may have struggled with the same problem as you are when I was working
on the diagram assistants (i.e. the popup bar and connection handles).
The diagram assistant editpolicies are installed on top-level shapes by
default to react to mouse events over the shape. I wanted the diagram
assistants to appear even if the user was hovering over a compartment on
the shape, but as you saw, the mouse events weren't being propogated to
the top-level figure.

To fix this, I created a DelegatingMouseEventsEditPolicy which forwards
all mouse events on its figure (i.e. the compartment) to the parent's
editpolicy of the same role.

Take a look at the code in DelegatingMouseEventsEditPolicy and where it
is installed to understand how it works. This editpolicy is private at
this point, but could be made public I suppose if it is useful to
others. There may be a better way to accomplish this in a more correct
GEF way as I don't think having an editpolicy that delegates mouse
events is something that GEF would do. See
http://help.eclipse.org/help32/topic/org.eclipse.draw2d.doc. isv/guide/hittest.html
for some information on hit testing in GEF which may be of use.

Hope this helps.

- Cherie

Jiri Semecky wrote:
> Hi,
>
> I'm trying to handle mouse events on particular subfigures of an EditPart.
> I added org.eclipse.draw2d.MouseListener to figures (subclasses of
> org.eclipse.draw2d.Figure) in XXXFigure.createContents() method.
>
> However the events are caught only if the EditPart consists of a single
> Figure. If the figure is more complex (composed of several subfigures,
> e.g. compartments), the events do not get to the figure. They are caught
> by an instance of ShapeCompartmentFigure, DefaultSizeNodeFigure,
> WrapLabel or so, but they are not propagated to the figure directly
> created in createContents().
>
> Please, how can be the mouse event handled for subregions of an
> EditPart? The EditPolicy mechanism doesn't work here, because it is only
> EditPart-grained (without the information which subfigure was clicked).
>
> Thanks for any hint,
> Jirka
Previous Topic:Connection handle behaviour
Next Topic:Link bend-point from a connection to a node
Goto Forum:
  


Current Time: Sun Jul 20 16:21:19 EDT 2025

Powered by FUDForum. Page generated in 0.71744 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top