distinguish between single click and double click [message #449961] |
Wed, 02 February 2005 03:18 |
Eclipse User |
|
|
|
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 #449969 is a reply to message #449962] |
Wed, 02 February 2005 12:38 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02580 seconds