Skip to content

Commit

Permalink
rebinding brackets [] to select-prev/select-next
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed Oct 2, 2024
1 parent c2cf510 commit 8b8a9ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion config/custom-keybinds.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"provider": "graphene"
},
"keyx": false,
"control+shift+keyx": "clear-segments"
"control+shift+keyx": "clear-segments",
"bracketleft": "select-previous",
"bracketright": "select-next"
}
18 changes: 12 additions & 6 deletions src/ui/default_viewer_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { bindTitle } from "#src/ui/title.js";
import type { Tool } from "#src/ui/tool.js";
import { restoreTool } from "#src/ui/tool.js";
import { UrlHashBinding } from "#src/ui/url_hash_binding.js";
import type { EventActionMap } from "#src/util/event_action_map.js";
import {
verifyObject,
verifyObjectProperty,
Expand Down Expand Up @@ -106,16 +107,21 @@ export function setupDefaultViewer() {
};

if (hasCustomBindings) {
const deleteKey = (map: EventActionMap, key: string) => {
map.delete(key);
for (const pMap of map.parents) {
deleteKey(pMap, key);
}
};

for (const [key, val] of Object.entries(CUSTOM_BINDINGS!)) {
deleteKey(viewer.inputEventBindings.global, key);
deleteKey(viewer.inputEventBindings.perspectiveView, key);
deleteKey(viewer.inputEventBindings.sliceView, key);
if (typeof val === "string") {
viewer.inputEventBindings.global.set(key, val);
} else if (typeof val === "boolean") {
if (!val) {
viewer.inputEventBindings.global.delete(key);
viewer.inputEventBindings.global.parents.map((parent) =>
parent.delete(key),
);
}
// not doing anything because we just use this to delete keybinds
} else {
viewer.inputEventBindings.global.set(key, `tool-${val.tool}`);
const layerConstructor = layerTypes.get(val.layer);
Expand Down

1 comment on commit 8b8a9ea

@jasper-tms
Copy link

Choose a reason for hiding this comment

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

Thanks a ton @chrisj for this and the annotation tagging hotkeys!!

Please sign in to comment.