I think this is OK, because mostly single click does some kind of select action, and it is probably ok to perform the select action even if you react to a double click event (open action or something, right?) moments later.

-- Edvin

Den 06.05.2011 13:45, skrev Greg Brown:
Pivot does not make a distinction between single clicks and double
clicks. A click of count 1 will always precede a click with count 2 and
so on. As I recall, this is similar to how mouse events are handled in
AWT/Swing.

Handling it any other way would require the platform to wait for some
period of time after a single click has occurred to make sure that the
user isn't going to click again, which could introduce some subtle (and
quite possibly annoying) usability issues.

G

On May 5, 2011, at 8:37 PM, Le Zhou wrote:

Thank you for your quick response. Maybe, i didn't make the problem
clear.

I mean the mouse double click event will trigger both mouse single
click processing logic and double click processing logic.

I think one mouse double click event makes the mouseClick method
called twice, with count=1 and count=2 respectively. So using if-else
to check count and does corresponding processing in the mouseClick
method doesn't work.
For example, i changed the mouseClick method as below:

@Override
public boolean mouseClick(Component component, Button button, int x,
int y, int count) {
if (count == 1) {
System.out.println("Single Click");
return true;
} else if (count == 2) {
System.out.println("Double Click");
return true;
}
return false;
}

One "Double Click" makes the app output

Single Click
Double Click

Actually, i think one N-click event makes the mouseClick method called
for N times, with count = 1,2,...,N-1,N respectively. So if I changed
the mouseClick method as below and performs a "triple click",

@Override
public boolean mouseClick(Component component, Button button, int x,
int y, int count) {
if (count == 1) {
System.out.println("Single Click");
return true;
} else if (count == 2) {
System.out.println("Double Click");
return true;
} else if (count == 3) {
System.out.println("Triple Click");
return true;
}
return false;
}

The app will output:

Single Click
Double Click
Triple Click

I hope i make the problem clear this time :)

Any suggestions? Thanks a lot!

On Thu, May 5, 2011 at 3:36 PM, Chris Bartlett <[email protected]
<mailto:[email protected]>> wrote:

    > So how to distinguish mouse single click and mouse double click?
    Thanks a lot!
    You should just be able to check the value of 'count' and only
    execute your double click code when there have been 2 mouse clicks.
    You might also check which mouse button the clicks came from.

    tableView.getComponentMouseButtonListeners().add(new
    ComponentMouseButtonListener() {

    @Override
    public boolean mouseClick(Component component, Button button, int
    x, int y, int count) {
    if (count == 1) {
    // Single click
    return true;
    } else if (count == 2) {
    // Double click
    return true;
    }
    System.out.println(count);
    return false;
    }
    });



    On 5 May 2011 14:08, Le Zhou <[email protected]
    <mailto:[email protected]>> wrote:

        Hi all,

        I added one ComponentMouseButtonListener instance to one
        TableView instance, and overrided the mouseClick method of
        ComponentMouseButtonListener class.
        When i performed one double click on the TableView, the
        mouseClick method was called twice. Below are snippet of the
        experiment code:

        tableView.getComponentMouseButtonListeners().add(new
        ComponentMouseButtonListener() {

        @Override
        public boolean mouseClick(Component component, Button button,
        int x, int y, int count) {
        System.out.println(count);
        return false;
        }
        });

        When i performed one double click on the tableView, output is
        like below:

        1
        2

        I was kinda confused, because i thought the output should be "2".
        I thought the count argument in mouseClick method is used to
        distinguish mouse single click and mouse double click events.
        But as shown in the output, it seems that the mouseClick
        method is called twice in one mouse double click event: count
        is 1 in the 1st call and count is 2 in the 2nd call.

        So how to distinguish mouse single click and mouse double
        click? Thanks a lot!





Reply via email to