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

Rework onKey event options #103

Merged
merged 7 commits into from
May 25, 2024
Merged

Rework onKey event options #103

merged 7 commits into from
May 25, 2024

Conversation

LeStegii
Copy link
Collaborator

@LeStegii LeStegii commented May 23, 2024

General

  • Added a strict option: If strict is enabled, setting an option like shift to false now requires the key not to be pressed instead of simply being ignored.

Additional information

I'm not sure if this is the best solution. While it keeps backwards compatibility and doesn't break any behavior, it has the downside of not covering all situations that would be possible with e.g. an enum.

With this implementation, either all or no settings are strict. This means it is not possible to require shift not to be pressed whilst not caring if alt is pressed or not.

Addressing #101

@LeStegii LeStegii requested a review from Clashsoft May 23, 2024 11:16
Comment on lines 465 to 468
(event.isShiftDown() && (!annotation.strict() || annotation.shift())) &&
(event.isControlDown() && (!annotation.strict() || annotation.control())) &&
(event.isAltDown() && (!annotation.strict() || annotation.alt())) &&
(event.isMetaDown() && (!annotation.strict() || annotation.meta()));
Copy link
Member

Choose a reason for hiding this comment

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

This boolean logic seems wrong, if the key is not down, the condition is never true

Copy link
Collaborator Author

@LeStegii LeStegii May 25, 2024

Choose a reason for hiding this comment

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

Fixed in latest commit
grafik

@LeStegii LeStegii marked this pull request as ready for review May 25, 2024 05:33
@LeStegii LeStegii requested a review from Clashsoft May 25, 2024 05:33
@Clashsoft Clashsoft merged commit 0eba1cf into master May 25, 2024
5 checks passed
@Clashsoft Clashsoft deleted the feat/strict-onkey branch May 25, 2024 19:41
@Clashsoft Clashsoft added the enhancement New feature or request label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants