On Wed, 24 Jul 2024 08:51:47 GMT, Jose Pereda <[email protected]> wrote:
>> modules/javafx.controls/src/main/java/javafx/scene/control/skin/TabPaneSkin.java >> line 947: >> >>> 945: case BOTTOM: >>> 946: // Consider vertical scroll events (dy > dx) >>> from mouse wheel and trackpad, >>> 947: // and horizontal scroll events from a >>> trackpad (dx > dy) >> >> Maybe we should explain why - to preserve the existing behavior with the >> mouse (scrolling up/down)? >> >> The trackpad events can have both `dx` and `dy` of various magnitude, both >> non-zero, so the logic seems to me a bit contrived - like filtering some >> events, although at the end it still feels ok. >> >> What do you think? > > (sorry I missed to reply) > > I believe the comment already states what are we taking into account, but > this is a more detailed explanation: > > - a mouse wheel only has vertical scroll events (`dx == 0`, so `abs(dy) > > abs(dx)`), then we just take `dy` to produce the horizontal scroll offset. > - a trackpad has both scroll events, and we take whichever is bigger. > Typically the user will do a horizontal scrolling if tabs are horizontally > laid out, and therefore abs(dy) <<< abs(dx), so we take `dx` to produce the > horizontal scroll offset, ignoring the smaller `dy` (that wouldn't have any > effect in any case). > > I'm happy to reword the comment if needed. Thank you! A larger question is that ideally we would need a mechanism to differentiate trackpad from mouse events, as they sometimes require different handling. We can't fully rely on the fact that either dx or dy is exactly 0.0, since theoretically we could get those events from the trackpad. What do you think? ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1486#discussion_r1690163418
