haxeui / haxeui-heaps

MIT License
31 stars 12 forks source link

Mouse events are now cancelled and the components' event order has been fixed #44

Closed tfabretti closed 1 year ago

tfabretti commented 1 year ago

Currently, the order of components mouse event processing is "older first". It means that, if I scroll, the first component to ask for notification will be the first notified of the event, so, if I have children in a parent, the parent will be the first notified. If the event is cancelled when computed, it means only the parent will be computed.

The builder works the other way. The children are the first to be notified, allowing to scroll a scroll view inside a scroll view, for example. Here is a builder : http://haxeui.org/builder/?e8c96d65 The child scroll view is scrolled but not the parent, because the event is cancelled when computed by the child. For the buttons, the stepper value is 10 because the child is computed first but buttons don't cancel events, so the parent is computed afterward and it sets the stepper to 10.

Heaps is doing it in the opposite way : the stepper displays 30. As for the scroll views, another issue is also present : the event cancellation is not present.

This PR adds the bubbling up of the cancellation of mouse events and the reversion of the order of event handling so children are processed first. I took inspiration from Flixel's backend code, although the latter doesn't reverse the list of callbacks. Either the order of callbacks is different or the ordering issue is present there.

ianharrigan commented 1 year ago

thanks so much for this - this is a great find! I never even realised the inconstancies in haxeui-heaps, so great you not only noticed them, but fixed them!

Thanks again!