Skip to content

Fix modifier order in keycode string generation #108260

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

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

Conversation

Silver1063
Copy link

Fix the order in which modifier keys are appended in as_text() and keycode_get_string() to ensure consistent and logical ordering (Ctrl, Alt, Shift, Meta). Refactored keycode_get_string() to use a vector for building the key string, improving readability and maintainability.

For example, creating a PopupMenu with an accelerator with ctrl, shift, n would result in the text displayed as "Shift + Ctrl + N" while adding the short cut with event N and modifiers ctrl and shift would result in text displayed as "Ctrl + Shift + N".

Both are now consistent.

Fix the order in which modifier keys are appended in as_text() and keycode_get_string() to ensure consistent and logical ordering (Ctrl, Alt, Shift, Meta). Refactored keycode_get_string() to use a vector for building the key string, improving readability and maintainability.
@Silver1063 Silver1063 requested review from a team as code owners July 4, 2025 00:24
@Chaosus Chaosus added this to the 4.6 milestone Jul 4, 2025
Copy link
Contributor

@Sauermann Sauermann left a comment

Choose a reason for hiding this comment

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

It looks like the chosen order is consistent with reccomendations from Windows and Mac (https://superuser.com/questions/1238058/key-combination-order). So this PR is headed in the right direction.
I believe, that it is unlikely, that this change will affect users negatively. (that would require users to process the text output, which seems a silly idea)

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

I suggest adding unit tests for this in tests/core/input/test_input_event_key.h (look for existing instances of as_text in that file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants