detecting single mouse clicks in a simple way ? [message #177337] |
Wed, 13 April 2005 18:52 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Pratik Shah 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 |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03568 seconds