Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » MouseDoubleClick event
MouseDoubleClick event [message #445263] Sun, 31 October 2004 14:07 Go to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I have a list control with a SelectionListener attached to it. The problem
is that when I double-click an item in the list first is called the
widgetSelected() method and then the widgetDefaultSelected() method. I need
to filter the widgetSelected method invocation, how can I do that ?
I know that is this system specific event generation, ex. Win32:
"Double-clicking the left mouse button actually generates a sequence of four
messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP.
"
But is there a method to avoid this ?

The only solution I found for this is to make a thread when Selection event
is generated and sleep this thread for doubleClickTime amount (a little bit
more) and if the DefaultSelection event still not arrived consider that was
a Selection event (only mouse down).
Is there another solution for this ?

Best regards,
Boby
Re: MouseDoubleClick event [message #445265 is a reply to message #445263] Mon, 01 November 2004 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: liankun_mail.21cn.com

You can listen the MouseEvent directly.The SelectionListener is listen to
the MouseEvnet and invoke your method .Why not do it directly?

"Robert Bacs" <boby@zerosoft.ro> д
Re: MouseDoubleClick event [message #445269 is a reply to message #445265] Mon, 01 November 2004 09:46 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

The MouseEvent is even worst because this is what I saw with the
MouseListener:

....
list.addMouseListener(new MouseListener(){
public void mouseDoubleClick(MouseEvent e){
System.out.println("mouseDoubleClick");
}
public void mouseDown(MouseEvent e){
System.out.println("mouseDown");
}
public void mouseUp(MouseEvent e){
System.out.println("mouseUp");
}
});

On simple click in the output:
mouseDown
mouseUp

On doubleclik in the output:
mouseDown
mouseUp
mouseDown
mouseDoubleClick
mouseUp

Lets say that on simple-click I must do action ONE and on double-click
action TWO. If I use mouseUp event the problem is that when the user
double-clicks an item I make two action - ONE for the first mouseUp event
and action TWO for the second mouseUp event after mouseDoubleClick event.
How can I make to avoid executing the first action on double-click ?

Regards,
Boby


"JeffLian" <liankun_mail@21cn.com> wrote in message
news:cm4jck$asr$1@eclipse.org...
> You can listen the MouseEvent directly.The SelectionListener is listen to
> the MouseEvnet and invoke your method .Why not do it directly?
>
> "Robert Bacs" <boby@zerosoft.ro> д
Re: MouseDoubleClick event [message #445271 is a reply to message #445269] Mon, 01 November 2004 11:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: liankun_mail.21cn.com

oh, May be the timer solution is appropriate.


"Robert Bacs" <boby@zerosoft.ro> д
Re: MouseDoubleClick event [message #445276 is a reply to message #445263] Mon, 01 November 2004 14:37 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Waiting is the right thing to do, even if you were a native MFC application.
The issue is that in a mouse down, you have no way of knowing whether there
is another mouse down coming that will cause a double select, other than
waiting for it. Investigate Display.addTimer() instead of spawning a
thread. Be warned that widgetDefaultSelected() can come from the keyboard
as well as from the mouse, depending on the platform.

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:cm2rjc$afb$1@eclipse.org...
> Hi,
>
> I have a list control with a SelectionListener attached to it. The problem
> is that when I double-click an item in the list first is called the
> widgetSelected() method and then the widgetDefaultSelected() method. I
need
> to filter the widgetSelected method invocation, how can I do that ?
> I know that is this system specific event generation, ex. Win32:
> "Double-clicking the left mouse button actually generates a sequence of
four
> messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and
WM_LBUTTONUP.
> "
> But is there a method to avoid this ?
>
> The only solution I found for this is to make a thread when Selection
event
> is generated and sleep this thread for doubleClickTime amount (a little
bit
> more) and if the DefaultSelection event still not arrived consider that
was
> a Selection event (only mouse down).
> Is there another solution for this ?
>
> Best regards,
> Boby
>
>
Re: MouseDoubleClick event [message #445289 is a reply to message #445276] Mon, 01 November 2004 16:54 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

Do you mean Display.timerExec() ?
I don't see any addTimer() method in Display class.

Yes, it's much better to execute in the user-interface thread than spawning
a new thread but I tried in an asyncExec() - didn't work and I missed the
timerExec() :).

Thanks and regards,
Boby



"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:cm5hn8$int$1@eclipse.org...
> Waiting is the right thing to do, even if you were a native MFC
application.
> The issue is that in a mouse down, you have no way of knowing whether
there
> is another mouse down coming that will cause a double select, other than
> waiting for it. Investigate Display.addTimer() instead of spawning a
> thread. Be warned that widgetDefaultSelected() can come from the keyboard
> as well as from the mouse, depending on the platform.
>
> "Robert Bacs" <boby@zerosoft.ro> wrote in message
> news:cm2rjc$afb$1@eclipse.org...
> > Hi,
> >
> > I have a list control with a SelectionListener attached to it. The
problem
> > is that when I double-click an item in the list first is called the
> > widgetSelected() method and then the widgetDefaultSelected() method. I
> need
> > to filter the widgetSelected method invocation, how can I do that ?
> > I know that is this system specific event generation, ex. Win32:
> > "Double-clicking the left mouse button actually generates a sequence of
> four
> > messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and
> WM_LBUTTONUP.
> > "
> > But is there a method to avoid this ?
> >
> > The only solution I found for this is to make a thread when Selection
> event
> > is generated and sleep this thread for doubleClickTime amount (a little
> bit
> > more) and if the DefaultSelection event still not arrived consider that
> was
> > a Selection event (only mouse down).
> > Is there another solution for this ?
> >
> > Best regards,
> > Boby
> >
> >
>
>
Re: MouseDoubleClick event [message #445327 is a reply to message #445289] Tue, 02 November 2004 15:24 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Yup, I meant Display.timerExec().

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:cm5pnc$34s$1@eclipse.org...
> Hi,
>
> Do you mean Display.timerExec() ?
> I don't see any addTimer() method in Display class.
>
> Yes, it's much better to execute in the user-interface thread than
spawning
> a new thread but I tried in an asyncExec() - didn't work and I missed the
> timerExec() :).
>
> Thanks and regards,
> Boby
>
>
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:cm5hn8$int$1@eclipse.org...
> > Waiting is the right thing to do, even if you were a native MFC
> application.
> > The issue is that in a mouse down, you have no way of knowing whether
> there
> > is another mouse down coming that will cause a double select, other than
> > waiting for it. Investigate Display.addTimer() instead of spawning a
> > thread. Be warned that widgetDefaultSelected() can come from the
keyboard
> > as well as from the mouse, depending on the platform.
> >
> > "Robert Bacs" <boby@zerosoft.ro> wrote in message
> > news:cm2rjc$afb$1@eclipse.org...
> > > Hi,
> > >
> > > I have a list control with a SelectionListener attached to it. The
> problem
> > > is that when I double-click an item in the list first is called the
> > > widgetSelected() method and then the widgetDefaultSelected() method. I
> > need
> > > to filter the widgetSelected method invocation, how can I do that ?
> > > I know that is this system specific event generation, ex. Win32:
> > > "Double-clicking the left mouse button actually generates a sequence
of
> > four
> > > messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and
> > WM_LBUTTONUP.
> > > "
> > > But is there a method to avoid this ?
> > >
> > > The only solution I found for this is to make a thread when Selection
> > event
> > > is generated and sleep this thread for doubleClickTime amount (a
little
> > bit
> > > more) and if the DefaultSelection event still not arrived consider
that
> > was
> > > a Selection event (only mouse down).
> > > Is there another solution for this ?
> > >
> > > Best regards,
> > > Boby
> > >
> > >
> >
> >
>
>
Previous Topic:display error with InputDialog and second not editable text field?
Next Topic:SWT Swing Interaction - JPopupMenu hide/show
Goto Forum:
  


Current Time: Sat Apr 20 09:43:18 GMT 2024

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

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

Back to the top