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

Macro: #3713 - Hot keys for toolbar buttons are not implemented in Macromoleculas view #3836

Merged
merged 5 commits into from
Jan 5, 2024

Conversation

rrodionov91
Copy link
Collaborator

@rrodionov91 rrodionov91 commented Jan 4, 2024

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

const hotKeys = initHotKeys(keySettings);
const shortcutKey = keyNorm.lookup(hotKeys, event);

if (keySettings[shortcutKey] && keySettings[shortcutKey].handler) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can simplify

if (keySettings[shortcutKey]?.handler)


setupHotKeysEvents() {
this.hotKeyEventHandler = (event) => this.handleHotKeyEvents(event);
document.addEventListener('keydown', this.hotKeyEventHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just simply?

setupHotKeysEvents() {
  document.addEventListener('keydown', this. handleHotKeyEvents);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, because we need to bind 'this' to hotKeyEventHandler method. And this.hotKeyEventHandler.bind(this) also didn't work because it returns another function and it did not clear event listener in this case.

@rrodionov91 rrodionov91 merged commit 0d31614 into master Jan 5, 2024
5 checks passed
@rrodionov91 rrodionov91 deleted the 3713-hot-keys-for-macromolecules branch January 5, 2024 15:57
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.

Macro: Hot keys for toolbar buttons are not implemented in Macromoleculas view
3 participants