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

Don't change language setting with scroll wheel #3928

Merged
merged 1 commit into from
Nov 19, 2023

Conversation

HebaruSan
Copy link
Member

Problem

For about 3 years now, we have had sporadic reports of the CKAN GUI using an unexpected language, initially Chinese, later French, occasionally other languages.

Cause

Extensive, repeated audits of the code in search of bugs turned up a few leads that ultimately were dead ends. The code for defaulting the language initially, saving to/loading from disk, and the settings dialog are about as simple and robust as could be hoped, and we were not able to reproduce the problem with any imagined set of steps.

However, today a user shared a video that might explain what has been happening:

If the user thinks the dialog may be scrollable (many modern UIs hide the scrollbar until scrolling happens 😵‍💫), they may flick the mouse wheel to try to expose more settings. If the mouse cursor happens to be hovering over the language dropdown (a rare coincidence to be sure, but the reports of the problem have also been pretty rare), this changes its value, even without clicking it. This is the default behavior of comboboxes in WinForms, but it's unhelpful and surprising in this case.

Changes

Now this dropdown has a handler for the MouseWheel event, which casts its MouseEventArgs argument to HandledMouseEventArgs in order to set Handled = true, which prevents the control from reacting to the mouse wheel. Appropriately, users will have to click to change the setting.

Yes, this is the documented way to access this API (!!):

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.handledmouseeventargs?view=windowsdesktop-7.0#remarks

HandledMouseEventArgs is not passed directly by MouseEventHandler when it handles the MouseWheel event. Rather, MouseEventHandler uses a MouseEventArgs, which you must cast to a HandledMouseEventArgs in order to cancel an occurrence of MouseWheel."

Fixes #3244. (Probably? We'll see if anyone reports it again after this fix goes public.)

@HebaruSan HebaruSan added the GUI Issues affecting the interactive GUI label Nov 17, 2023
Copy link
Member

@techman83 techman83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well. How annoying is that! Good find @HebaruSan !!

@HebaruSan HebaruSan merged commit 3da1f04 into KSP-CKAN:master Nov 19, 2023
10 checks passed
@HebaruSan HebaruSan deleted the fix/settings-lang-scroll branch November 19, 2023 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

All text is in Chinese after update
2 participants