Reputation: 4615
Is there a standard way to separate MouseClick and MouseDown events in GWT?
If I click and hold button I still get MouseClick event together with MouseUp.
if I just click I still get MouseDown event together with MouseClick.
Upvotes: 0
Views: 2138
Reputation: 3671
These events have some differences. Handle events which you need in a particular situation.
The thing is that in a general case ClickEvent
includes MouseDownEvent
and MouseUpEvent
and cannot take place without of them. MouseDownEvent
and MouseUpEvent
precede ClickEvent
. The same way as ClickEvent
precedes DoubleClickEvent
. But MouseDownEvent
doesn't garantee that an ClickEvent
will occur.
MouseDownEvent
occurs every time when a user presses on one of the mouse buttons inside any element.
MouseUpEvent
occurs when a user releases one of any mouse buttons.
and ClickEvent
consists of both of these events. ClickEvent
occurs when there're both these events on the same element. It's something like a combination of the mouse down and mouse up events. ClickEvent
is generated only for the left mouse button unlike MouseDownEvent
and MouseUpEvent
.
That's ClickEvent
is generated when a mouse is down then up while over an elem.
However, the mouse must stay within the same element, otherwise it won't occur.
For example, you pressed mouse down and moved outside of the element and release it. ClickEvent
will not generated but MouseDownEvent
will in this case.
And if you press mouse down and move outside the element, and move back in, then release it. ClickEvent
will occur. And MouseDownEvent
with MouseUpEvent
will too.
If a user did click then this is the sequence of events:
ClickEvent
fires only after a user has released his mouse button.
Butt there's a way to create ClickEvent
without generating of MouseDownEvent
and MouseUpEvent
:
Alternatively, you can open a link without generating ClickEvent
:
MouseDownEvent
and MouseUpEvent
will fire)Upvotes: 6