Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » distinguish between single click and double click
distinguish between single click and double click [message #449961] Wed, 02 February 2005 03:18 Go to next message
Eclipse UserFriend
Originally posted by: vafada2.yahoo.com

i have a Shell that has a MouseListener attached to it... double
clicking the mouse in the shell invokes all three methods in the
MouseListener (which should be the case) but i want to determine if the
user double clicks or single click my shell... how do i distinguish
between a single click and a double click? is there a SWT counterpart of
Swing's MouseEvent.getClickCount() ?
Re: distinguish between single click and double click [message #449962 is a reply to message #449961] Wed, 02 February 2005 09:34 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

There is no way to determine if it's a double-click or simple-click, because
if you double-click a shell, the first click will genereate a mouseDown()
event, and after double-click time will generate the mouseDoubleClick()
event. Howewer there is a solution that I'm using it in an application:

shell.addMouseListener(new MouseListener(){
private boolean mouseDoubleClick = false;

public void mouseDoubleClick(MouseEvent e) {
mouseDoubleClick = true;
System.out.println("DoubleClick");
}

public void mouseDown(MouseEvent e) {
Display display = Display.getDefault();
mouseDoubleClick = false;

display.timerExec(display.getDoubleClickTime(), new Runnable() {

public void run() {
if (mouseDoubleClick){
return;
}
else {
System.out.println("SimpleClick");
}
}
});
}

public void mouseUp(MouseEvent e) {
}
});

Regards,
Boby

"bryan yu" <vafada2@yahoo.com> wrote in message
news:ctpgqi$2tm$1@www.eclipse.org...
> i have a Shell that has a MouseListener attached to it... double
> clicking the mouse in the shell invokes all three methods in the
> MouseListener (which should be the case) but i want to determine if the
> user double clicks or single click my shell... how do i distinguish
> between a single click and a double click? is there a SWT counterpart of
> Swing's MouseEvent.getClickCount() ?
Re: distinguish between single click and double click [message #449969 is a reply to message #449962] Wed, 02 February 2005 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bryanyu.dualforcesolutions.com

works perfectly.. thanks Robert

Robert Bacs wrote:
> Hi,
>
> There is no way to determine if it's a double-click or simple-click, because
> if you double-click a shell, the first click will genereate a mouseDown()
> event, and after double-click time will generate the mouseDoubleClick()
> event. Howewer there is a solution that I'm using it in an application:
>
> shell.addMouseListener(new MouseListener(){
> private boolean mouseDoubleClick = false;
>
> public void mouseDoubleClick(MouseEvent e) {
> mouseDoubleClick = true;
> System.out.println("DoubleClick");
> }
>
> public void mouseDown(MouseEvent e) {
> Display display = Display.getDefault();
> mouseDoubleClick = false;
>
> display.timerExec(display.getDoubleClickTime(), new Runnable() {
>
> public void run() {
> if (mouseDoubleClick){
> return;
> }
> else {
> System.out.println("SimpleClick");
> }
> }
> });
> }
>
> public void mouseUp(MouseEvent e) {
> }
> });
>
> Regards,
> Boby
>
> "bryan yu" <vafada2@yahoo.com> wrote in message
> news:ctpgqi$2tm$1@www.eclipse.org...
>
>>i have a Shell that has a MouseListener attached to it... double
>>clicking the mouse in the shell invokes all three methods in the
>>MouseListener (which should be the case) but i want to determine if the
>>user double clicks or single click my shell... how do i distinguish
>>between a single click and a double click? is there a SWT counterpart of
>>Swing's MouseEvent.getClickCount() ?
>
>
>
Re: distinguish between single click and double click [message #449972 is a reply to message #449969] Wed, 02 February 2005 15:21 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

However, the reason you can't distinguish is by definition single-click
means select, and then double-click means do default action based upon
the selection done in the first click. So they are meant to be
associated with each other. So the first click is supposed to selection,
no matter whether it came from a single click or a double click.



--
Thanks,
Rich Kulp
Previous Topic:Generating executable JAR file from Eclipse 3.1M4
Next Topic:Program.findProgram
Goto Forum:
  


Current Time: Thu Apr 18 16:07:53 GMT 2024

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

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

Back to the top