Open zmeyc opened 7 years ago
This is an issue on more than just iOS. TOUCH_UP is emitted twice (not TOUCH_DOWN).
The second (bubbles:false) event is dispatched within "Actor::_onGlobalTouchUpEvent".
I can't make heads or tails of the intended logic within Actor involving _overred, _pressedButton, and _pressedOvered. It looks like it might be trying to add handlers to generate TOUCH_UP/MOVE events on an Actor that received TOUCH_DOWN previously, regardless of the current mouse position.
I can't help but think this needs a bit of an overhaul. It seems to be designed around originally only supporting a single pointer perhaps?
Each Actor maintaining its own mouse button state seems wrong in general. Why is this being done?
It is known bug. there is workaround: you should check if 'bubbles' flag = false
example:
void GameScene::onEvent(Event *ev)
{
if (ev->type == TouchEvent::TOUCH_UP && ev->bubbles == false)
{
someStuff();
}
}
I can't help but think this needs a bit of an overhaul. It seems to be designed around originally only supporting a single pointer perhaps?
Each Actor maintaining its own mouse button state seems wrong in general. Why is this being done?
It is designed for multitouches. Thats why each actor has own state
It is designed for multitouches. Thats why each actor has own state
Yeah, but why is the state stored in each Actor? Why can't objects deriving from Actor register event handlers and deal with touch events normally on their own? It looks like the whole point of Actor keeping track of which pointer "overred" and "pressed" it is so it can register _onGlobalTouchMoveEvent and _onGlobalTouchUpEvent. Why are those handlers needed?
And then _overred is a pointer_index and _pressedButton is an array of pointer_index. So the Actor code can only remember a single "pointer" that "overred" or "pressed" it (per button). That doesn't seem multi-touch compliant.
TLDR: Why does Actor register touch event handlers at all? Why can't derived classes handle all the touch events as needed?
On iOS simulator TOUCH_UP and MOVE events are emitted once, but TOUCH_DOWN is emitted twice (with bubbling: true, then bubbling: false).
Steps to reproduce: