Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » detecting single mouse clicks in a simple way ?
detecting single mouse clicks in a simple way ? [message #177337] Wed, 13 April 2005 18:52 Go to next message
Eclipse UserFriend
Originally posted by: hoe.zurich.ibm.com

What's the best way to detect single mouse clicks on an EditPart in a
*simple* manner? (I need it for expand / collapse, not for changing
anything in the model, BTW.)

I've read that it can be spotted as direct_edit on an already selected
EditPart; that means overriding 1) EditPart.performRequest (to handle
direct_edit), 2) selectedStateChanged (for when its not yet selected),
and 3) activate/deactive (to add/remove as EditPartListener).

While this seems to work, it is also cumbersome, and the direct_edit
only fires after a delay, whose duration seems to be hardcoded in.

Who knows a better / simpler way, and can perhaps point to a source code
example (e.g. a EditPolicy that does the trick) ?

Thanks,
Christian
Re: detecting single mouse clicks in a simple way ? [message #177372 is a reply to message #177337] Wed, 13 April 2005 20:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gslade.no.spam.us.ibm.com

Hi Christian

One way to do what you want is for the edit part to add a MouseListener
to the figure(s). You could implement this as an inner class and then
respond to the mousePressed event by calling a method in the edit part
that did whatever it needed to do and then refreshed its visuals.

Guy

Christian Hoertnagl wrote:
> What's the best way to detect single mouse clicks on an EditPart in a
> *simple* manner? (I need it for expand / collapse, not for changing
> anything in the model, BTW.)
>
> I've read that it can be spotted as direct_edit on an already selected
> EditPart; that means overriding 1) EditPart.performRequest (to handle
> direct_edit), 2) selectedStateChanged (for when its not yet selected),
> and 3) activate/deactive (to add/remove as EditPartListener).
>
> While this seems to work, it is also cumbersome, and the direct_edit
> only fires after a delay, whose duration seems to be hardcoded in.
>
> Who knows a better / simpler way, and can perhaps point to a source code
> example (e.g. a EditPolicy that does the trick) ?
>
> Thanks,
> Christian
Re: detecting single mouse clicks in a simple way ? [message #177416 is a reply to message #177372] Wed, 13 April 2005 21:25 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
And the palette is an example of this. The palette is a GraphicalViewer,
and clicking on the drawer's title expands and collapses that drawer.

"Guy Slade" <gslade.no.spam@us.ibm.com> wrote in message
news:d3k11b$7mt$1@news.eclipse.org...
> Hi Christian
>
> One way to do what you want is for the edit part to add a MouseListener
> to the figure(s). You could implement this as an inner class and then
> respond to the mousePressed event by calling a method in the edit part
> that did whatever it needed to do and then refreshed its visuals.
>
> Guy
>
> Christian Hoertnagl wrote:
> > What's the best way to detect single mouse clicks on an EditPart in a
> > *simple* manner? (I need it for expand / collapse, not for changing
> > anything in the model, BTW.)
> >
> > I've read that it can be spotted as direct_edit on an already selected
> > EditPart; that means overriding 1) EditPart.performRequest (to handle
> > direct_edit), 2) selectedStateChanged (for when its not yet selected),
> > and 3) activate/deactive (to add/remove as EditPartListener).
> >
> > While this seems to work, it is also cumbersome, and the direct_edit
> > only fires after a delay, whose duration seems to be hardcoded in.
> >
> > Who knows a better / simpler way, and can perhaps point to a source code
> > example (e.g. a EditPolicy that does the trick) ?
> >
> > Thanks,
> > Christian
Re: detecting single mouse clicks in a simple way ? [message #177470 is a reply to message #177416] Thu, 14 April 2005 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hoe.zurich.ibm.com

Guy, Patrik,

Thanks for you quick and specific reply: this works for me. There is
sample code in
org.eclipse.gef.internal.ui.palette.editparts.DrawerFigure (and
DrawerEditPart).

Christian

Pratik Shah wrote:
> And the palette is an example of this. The palette is a GraphicalViewer,
> and clicking on the drawer's title expands and collapses that drawer.
>
> "Guy Slade" <gslade.no.spam@us.ibm.com> wrote in message
> news:d3k11b$7mt$1@news.eclipse.org...
>
>>Hi Christian
>>
>>One way to do what you want is for the edit part to add a MouseListener
>>to the figure(s). You could implement this as an inner class and then
>>respond to the mousePressed event by calling a method in the edit part
>>that did whatever it needed to do and then refreshed its visuals.
>>
>>Guy
>>
>>Christian Hoertnagl wrote:
>>
>>>What's the best way to detect single mouse clicks on an EditPart in a
>>>*simple* manner? (I need it for expand / collapse, not for changing
>>>anything in the model, BTW.)
>>>
>>>I've read that it can be spotted as direct_edit on an already selected
>>>EditPart; that means overriding 1) EditPart.performRequest (to handle
>>>direct_edit), 2) selectedStateChanged (for when its not yet selected),
>>>and 3) activate/deactive (to add/remove as EditPartListener).
>>>
>>>While this seems to work, it is also cumbersome, and the direct_edit
>>>only fires after a delay, whose duration seems to be hardcoded in.
>>>
>>>Who knows a better / simpler way, and can perhaps point to a source code
>>>example (e.g. a EditPolicy that does the trick) ?
>>>
>>>Thanks,
>>>Christian
Re: detecting single mouse clicks in a simple way ? [message #177538 is a reply to message #177337] Thu, 14 April 2005 14:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The best way is to use a subclass of the Clickable figure, and add an
actionlistener to it.
The alternative is to implement your own clickable implementation.
Re: detecting single mouse clicks in a simple way ? [message #177553 is a reply to message #177538] Thu, 14 April 2005 14:56 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Sorry, not subclass, just use clickable.
Previous Topic:figures dont display in M6
Next Topic:Please Help!
Goto Forum:
  


Current Time: Thu Apr 25 11:36:12 GMT 2024

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

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

Back to the top