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

Ignore repeated key events for bound shortcuts, adjust visualization min width #9537

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

Frizi
Copy link
Contributor

@Frizi Frizi commented Mar 25, 2024

Pull Request Description

Fixes #8538 #9515

All repeated keyboard events handled through defineShortcuts are now ignored. For example, holding ctrl+v no longer pastes nodes repeatedly.

Also adjusted visualization min-width to 200px, since it was a trivial change.

image

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@Frizi Frizi linked an issue Mar 25, 2024 that may be closed by this pull request
@@ -391,6 +391,9 @@ export function defineKeybinds<
>,
): (event: Event_, stopAndPrevent?: boolean) => boolean {
return (event, stopAndPrevent = true) => {
// Do not handle repeated keyboard events (held down key).
if (event instanceof KeyboardEvent && event.repeat) return false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think returning false unconditionally in this case risks bugs: If the first event was handled by a shortcut and stopped, but the repeat events are not stopped, they could be handled by something else--which would probably be surprising.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what else we could do here. Returning true is not really correct either, as we don't handle the event. My reasoning was that since all handlers should perform this check, they all should not do anything else. This is currently true, since we always use the shortcut definitions when working with keyboard events. On the other hand, it leaves the possibility to explicitly allowing repeat key handling when we need it.

@Frizi Frizi added CI: Ready to merge This PR is eligible for automatic merge CI: No changelog needed Do not require a changelog entry for this PR. labels Mar 25, 2024
@mergify mergify bot merged commit 1872bb6 into develop Mar 25, 2024
39 of 43 checks passed
@mergify mergify bot deleted the wip/frizi/key-repeat branch March 25, 2024 19:29
jdunkerley pushed a commit that referenced this pull request Mar 26, 2024
…min width (#9537)

Fixes #8538 #9515

All repeated keyboard events handled through `defineShortcuts` are now ignored. For example, holding ctrl+v no longer pastes nodes repeatedly.

Also adjusted visualization min-width to 200px, since it was a trivial change.

![image](https://github.com/enso-org/enso/assets/919491/7997898f-bcee-45f2-aacb-e10a49b159d6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visualisation Minimum Width Holding down a shortcut invokes it repeatedly
3 participants