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 hotkeys info panel, extend HotkeyListener to support spacial hotkeys #1544

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

sergzak022
Copy link
Collaborator

No description provided.

@@ -58,7 +58,6 @@
"ol": "^6.14.1",
"ol-ext": "^3.2.22",
"orbit-controls-es6": "^2.0.1",
"platform-detect": "^3.0.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove platform-detect, because couldn't figure out in a reasonable amount of time how to resolve typescript errors associated with it when running jest tests.

@@ -444,6 +445,9 @@ export default Vue.extend({
},
show_ui_schema_context_menu: false,
hotkey_manager: null,
platform: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add platform instance variable to keep track of the client's OS

@@ -14,6 +14,7 @@
</ui_schema_context_menu>
<toolbar_factory
v-if="annotation_ui_context.working_file && annotation_ui_context.command_manager"
:platform="platform"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pass platform value to toolbar components

@@ -1898,16 +1898,14 @@ export default Vue.extend({
this.z_key = false
})

this.hotkey_listener.onKeydown({ keys: 'shift', scope }, () => {
this.hotkey_listener.onSpecialKeydown({ keys: 'shift', scope }, () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added onSpecialKeydown and onSpecialKeyup to bind to individual special hotkeys like shift, control, alt, command. This should be good enough for now. In the future we can make onKeyup/onKeydown to handle binding to these individual special keys. Right now onKeyup/onKeydown only support special keys like ctrl if it's a part of the combination that includes alphanumeric chars (also simbols like ?, !, etc) like ctrl+c

@@ -23,11 +23,11 @@
<p> <kbd>Shift</kbd> + <kbd>↑</kbd>,<kbd>↓</kbd> Previous or Next Attribute </p>
<p> <kbd>1-9</kbd> Change Attribute Options (Select & Radio) </p>
<h2> Instance </h2>
<p> <kbd>CTRL+ ←/→</kbd> Change Selected Instance</p>
<p> <kbd>{{ is_mac_os ? "⌘" : "Ctrl" }}</kbd> + <kbd>←/→</kbd> Change Selected Instance</p>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update hotkeys info panel for image and video annotation to replace ctrl with on Macs

@@ -468,7 +468,7 @@
:close_by_button="true"
>
<template slot="content">
<hotkeys></hotkeys>
<hotkeys :is_mac_os="platform === 'mac'"></hotkeys>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let hotkeys.vue know if client uses mac

return 'mac'
} else if (linux) {
return 'linux'
getPlatform() : Platform {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated getPlatform method to use custom code instead of platform-detect library

@@ -276,5 +284,98 @@ export class HotkeyListener {
}
}

private parseSpecialKeyBinding(binding: string) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extended HotkeyListener with onSpecialKeydown and onSpecialKeyup. Also added some private helper methods.

@@ -82,6 +82,8 @@ describe("Test annotation_core", () => {
addFilter: jest.fn(),
onKeyup: jest.fn(),
onKeydown: jest.fn(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix existing tests

@sergzak022 sergzak022 merged commit 2bd8cce into diffgram:hotkey Sep 12, 2023
4 of 7 checks passed
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.

None yet

1 participant