Skip to content

SP4 Controls: Prevent horizontal scroll wheel events from throwing exceptions#2600

Merged
swharden merged 5 commits intoScottPlot:mainfrom
bclehmann:fix/avaplot-horizontal-scroll-wheel
May 14, 2023
Merged

SP4 Controls: Prevent horizontal scroll wheel events from throwing exceptions#2600
swharden merged 5 commits intoScottPlot:mainfrom
bclehmann:fix/avaplot-horizontal-scroll-wheel

Conversation

@bclehmann
Copy link
Member

Purpose:
Fixes an issue reported by Svetlana in the discord. This appears to only affect the v4 Avalonia control.

Before this change an attempt to scroll horizontally would reach this line:

if (input.WheelScrolledDown == false && input.WheelScrolledUp == false)
throw new ArgumentException("mouse wheel was scrolled but neither direction is set");

This is fixed by simply ignoring horizontal scroll inputs (which I believe is what we implicitly do on other platforms). In principle we could also treat horizontal inputs as if they were vertical, which may be preferable on MacOS when the shift key is pressed (and in my opinion at no other time): AvaloniaUI/Avalonia#8628 (comment)

@swharden
Copy link
Member

Hi @bclehmann, thanks for reporting this! It took me a while to get to this (I was sick for a few weeks) but I am happy to resume work on it now.

Related to this PR, @szescxz found that the same exception may be thrown in the WPF control (#2626). I'll modify this PR by editing the backend to allow a fix for all controls then merge it today

@swharden swharden changed the title AvaPlot: Do not crash on horizontal scroll-wheel inputs SP4 Controls: Prevent horizontal scroll wheel events from throwing exceptions May 14, 2023
@swharden swharden linked an issue May 14, 2023 that may be closed by this pull request
@swharden swharden enabled auto-merge May 14, 2023 19:48
@swharden swharden merged commit 2ff461e into ScottPlot:main May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SP4: Scroll with no delta throws exception in WPF

2 participants