-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
click event is generated twice for buttons using the canvas renderer #108
Conversation
How can I reproduce the double click? I tested the button2 demo that has a button with a canvas renderer but it seemed to work just fine. I doubt the difference comes from different dom elements for the states because Lime does not listen events on separate dom elements, only for the container. |
I've just tested it and the button action seems to be stopping the second event. In that test instead of replacing the scene on the button action do a console.log or something like that, it should print twice to the console. |
(In case this hasn't made progress) I'm getting the same problem. The 2 events are actually different, the second one being more like a normal mouse event, with many more fields. My quick workaround is to filter out the second event: goog.events.listen(myButton, 'click', function (e) {
if (e.event) {
return; // Ignore dummy event
}
// actual event handling ...
} More detail:
The second event, which is not fired when DOM-rendering, has the following fields:
|
I am seeing this with a DOM renderer in the current codebase. I am trying to debug this now. Click seems to be fired twice. The normal click event from the browser, and the overridden click from 'button'. If i modify the events enum such that lime.Button.Event.CLICK === 'buttonClick', everything is working again. The problem seems to be that the browser 'click' is getting fired and a custom click is also dispatched from a button on 'mouseup'. Still trying to figure out the real fix for this. stringa |
I still can't see this happening with the DOM renderer in the current codebase. |
I landed the buttonClick fix. If someone finds a better fix then send new PR. |
This is still an issue and better fix is needed. Current implementation is very confusing. Codebase is still full of "click" event handlers(as literal strings) and for some reason they even work in Chrome. #120 is probably also just related to the renaming. I'm now in favor or keeping the "click" name. It would help to get some test cases about duplicate dispatches so I could tackle down the real issue here. |
This reverts commit fca9d7d.
I reverted the commit but can't reopen the issue for some reason. |
When using a DOM renderer the element that generates the "mousedown" event is different from the element that generates the "mouseup" event because of the different button states (up/down). Therefore it is necessary to manually fire the "click" event. But if the used renderer is canvas, it's the same element for both button states and the "click" event ends up being fired twice.