Skip to content

Commit d709480

Browse files
example scope changing WIP
1 parent 7800f58 commit d709480

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

frontend/src/components/annotation/image_and_video_annotation/annotation_core.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,12 @@ export default Vue.extend({
741741
watch: {
742742
is_active: function (){
743743
this.canvas_element.style.cursor = ''
744+
//console.log(this.is_active, this.working_file.id)
745+
let scope=`image ${this.working_file.id}`
746+
this.hotkey_listener.setScope(scope)
747+
console.log(this.hotkey_listener.scopeCallbackRegistry)
748+
console.log(this.hotkey_listener.selectedScopes)
749+
744750
},
745751
global_instance: function(){
746752
this.$emit('global_instance_changed', this.working_file.id, this.global_instance)
@@ -1729,7 +1735,7 @@ export default Vue.extend({
17291735
}
17301736
this.mounted();
17311737

1732-
this.hotkeyListenerScope = `image ${this.working_file.hash}`
1738+
this.hotkeyListenerScope = `image ${this.working_file.id}`
17331739

17341740
this.setupHotkeys(this.hotkeyListenerScope)
17351741

frontend/src/utils/hotkey_listener.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export type KeyEventHandler = (event: KeyboardEvent, handler: HotkeysEvent) => v
3131
* - **Flexible Unbinding**: Offers the ability to clear hotkeys, either entirely, by a specific scope, or by key combinations,
3232
* providing granular control over the registered hotkeys.
3333
*
34+
* How to Change Scope:
35+
* TBD
36+
*
3437
* Usage:
3538
*
3639
* 1. **Initialization**:
@@ -43,7 +46,7 @@ export type KeyEventHandler = (event: KeyboardEvent, handler: HotkeysEvent) => v
4346
*
4447
* 3. **Scopes**:
4548
* - Select scope and create if doesn't exist already: `listener.addScope('myScope')`.
46-
* - Cancle selection of a scope: `listener.removeScope('myScope')`.
49+
* - Cancel selection of a scope: `listener.removeScope('myScope')`.
4750
* - Delete scope and all hotkey bindings: `listener.deleteScope('myScope')`.
4851
* - Note: A hotkey will only trigger if its scope is among the selected scopes.
4952
*
@@ -143,6 +146,10 @@ export class HotkeyListener {
143146
return this.selectedScopes
144147
}
145148

149+
setScope(scope: string) {
150+
return this.selectedScopes = [scope]
151+
}
152+
146153
addScope(scope: string) {
147154
if (!this.selectedScopes.includes(scope)) {
148155
this.selectedScopes.push(scope)
@@ -312,6 +319,7 @@ export class HotkeyListener {
312319
preventDefaultEvent = DEFAULT_HOTKEYS_OPTIONS.preventDefaultEvent,
313320
} = opts
314321

322+
console.log(keys, scope, element)
315323

316324
const bindKeys = platformDependent
317325
? this.getPlatformBasedKeys(keys)

0 commit comments

Comments
 (0)