Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Clickable figure is not receiving mouse events.
Clickable figure is not receiving mouse events. [message #243405] Thu, 05 June 2008 17:03 Go to next message
Eclipse UserFriend
Originally posted by: lefty.rivera.gmail.com

I have the following code:

up = new Clickable(new Label("Up"));
up.setRolloverEnabled(true);
up.setBorder(ButtonBorder.TOOLBAR);
up.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
System.out.println("action performed");
}
});
up.setToolTip(new Label("Tooltip"));

The rollover, tooltip and action listener are not working but I see the
figure. I debugged the code and the figure is not receiving any mouse
events. Any ideas what can be causing this problem?
Re: Clickable figure is not receiving mouse events. [message #243796 is a reply to message #243405] Tue, 17 June 2008 20:10 Go to previous message
Thomas Kerle is currently offline Thomas KerleFriend
Messages: 13
Registered: July 2009
Junior Member
Hi,

If your are working in GEF (means not only in Draw2d) only the mouseDown
event is forwarded to the figures. You can test this by adding to your
figure a listener as follows:

myFigure.addMouseListener (new MouseListener() {
.. methods

@Override
public void mouseUp (...) {
//nothing will happen
}
});

This because the events are dispatched by GEF. A solution to keep the MVC -
pattern is to define your own tool and overwrite some methods which handle
the mouse events and forward them via model to the controller....

something (like this .. foregive me for this hack):

@Override
public void mouseDown (MouseEvent me, EditPartViewer viewer) {
super.mouseDown(me, viewer);
if (viewer.getContents() instanceof YourEditPart) {

Point current = getLocation().getCopy();

YourEditPart part = (YourEditPart) viewer.getContents();

YourModel model = (YourModel) part.getModel();

IFigure figure = part.getFigure();

figure.translateToRelative(current);
executeCommand (new DefaultMousePressCommand (model, current,
me.button));
}
}

it still remains a lot of work!

"Lefty A Rivera" <lefty.rivera@gmail.com> schrieb im Newsbeitrag
news:g2960k$rd5$1@build.eclipse.org...
>I have the following code:
>
> up = new Clickable(new Label("Up"));
> up.setRolloverEnabled(true);
> up.setBorder(ButtonBorder.TOOLBAR);
> up.addActionListener(new ActionListener(){
> public void actionPerformed(ActionEvent evt) {
> System.out.println("action performed");
> }
> });
> up.setToolTip(new Label("Tooltip"));
>
> The rollover, tooltip and action listener are not working but I see the
> figure. I debugged the code and the figure is not receiving any mouse
> events. Any ideas what can be causing this problem?
Previous Topic:Graphical viewer query
Next Topic:Problems with GEF diagram editor in a ViewPart
Goto Forum:
  


Current Time: Tue Sep 25 03:50:50 GMT 2018

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

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

Back to the top