Skip to content
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

Fix MouseWheelEventArgs.Delta from static to an instance readonly field #9947

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Oct 12, 2024

Description

Similarly as in #7910, the MouseWheelEventArgs.Delta is a static field, meaning a creation of a new event changes the Delta value for all previously created events. This is clearly a bug, the field shall not be static but an instanced readonly as the event should describe the state at the exact point of time it was generated.

Customer Impact

Creation of a new MouseWheelEventArgs will not influence the value of Delta for previous instances.

Regression

No.

Testing

Local build.

Risk

Low.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners October 12, 2024 13:01
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Oct 12, 2024
@h3xds1nz h3xds1nz changed the title Adjust MouseWheelEventArgs.Delta from static to an instance readonly field Fix MouseWheelEventArgs.Delta from static to an instance readonly field Oct 12, 2024
@miloush
Copy link
Contributor

miloush commented Oct 14, 2024

the event should describe the state at the exact point of time it was generated.

That is not such a clear cut, since as discussed in a few other issues here, mouse events/args tend to return the current state of the device rather than the state at the time the args were created. See the buttons state properties, coming from MouseDevice.GetButtonStateFromSystem or even the GetPosition, which reports the last received mouse position for any instance of the args. I can see how a similar behavior could have been the intent here (and in that light, the #7910 fix is questionable).

That said, wheel delta is not a state, it's an event, and it seems reasonable that you should be able to accumulate them, and accumulating with the current implementation gives you potentially incorrect results.

@h3xds1nz
Copy link
Member Author

Totally forgot; just wanted to say I fully agree with the statement @miloush, was just trying too hard to sell it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions Included in test pass PR metadata: Label to tag PRs, to facilitate with triage Status:Completed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants