Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsdetecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177337/#msg_177337
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]]>2005-04-13T18:52:18-00:00Re: detecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177372/#msg_177372
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]]>2005-04-13T20:49:55-00:00Re: detecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177416/#msg_177416
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]]>Pratik Shah2005-04-13T21:25:48-00:00Re: detecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177470/#msg_177470
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]]>2005-04-14T08:26:40-00:00Re: detecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177538/#msg_177538
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.]]>2005-04-14T14:56:35-00:00Re: detecting single mouse clicks in a simple way ?
https://www.eclipse.org/forums/index.php/mv/msg/55803/177553/#msg_177553
Originally posted by: none.us.ibm.com
Sorry, not subclass, just use clickable.]]>2005-04-14T14:56:50-00:00