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

Update key modifier functions #1152

Merged
merged 6 commits into from
Jan 31, 2024
Merged

Update key modifier functions #1152

merged 6 commits into from
Jan 31, 2024

Conversation

DanRStevens
Copy link
Collaborator

Closes #1151

Mark KeyModifier methods as static.

Remove Caps Lock checking from shift. We probably don't want to check Caps in that method. For control key combos, they should be unaffected by Caps. For text capitalization, we need to xor the state of Shift and Caps (rather than or them). Removing this check also makes the shift function consistent with query_shift.

Implement the query_ prefixed methods in terms of the static methods.

Strip the query_ prefix from non-static methods that query the current keyboard state.

We really shouldn't be merging these two checks. Shift behaviour is independent of Caps Locks for most control key combinations. For typing and capitalization, it should be XOR of Shift and Caps, not the OR of them.
Reduce code duplication. Ensure functions with similar names behave in the same manner. Previously the `shift` and `query_shift` functions treated Caps Lock differently.
There is sufficient context for function overloading to distinguish which method should be called. The main difference is if a `KeyModifier` is already known, or needs to be queried from the current keyboard state. When no `KeyModifier` is given, a reasonable assumption is to query for the information.

Removing the `_` makes the name more consistent with other methods, which prefer camelCase.
@DanRStevens DanRStevens merged commit 121411e into main Jan 31, 2024
8 checks passed
@DanRStevens DanRStevens deleted the keyModifierFunctions branch January 31, 2024 00:21
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.

EventHandler key modifier checks should be static
1 participant