From 85f3e23e7f6aa9cfaa8411fa25fbddd11268fe01 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 24 Jul 2022 16:52:18 +0200 Subject: [PATCH] [Editor] Fix few keyboard shortcuts on mac --- src/display/editor/editor.js | 11 ++++++++--- src/display/editor/tools.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index d890a9499..76fcd6110 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -16,7 +16,7 @@ // eslint-disable-next-line max-len /** @typedef {import("./annotation_editor_layer.js").AnnotationEditorLayer} AnnotationEditorLayer */ -import { bindEvents, ColorManager } from "./tools.js"; +import { bindEvents, ColorManager, KeyboardManager } from "./tools.js"; import { shadow, unreachable } from "../../shared/util.js"; /** @@ -249,12 +249,17 @@ class AnnotationEditor { * @param {PointerEvent} event */ pointerdown(event) { - if (event.button !== 0) { + const isMac = KeyboardManager.platform.isMac; + if (event.button !== 0 || (event.ctrlKey && isMac)) { // Avoid to focus this editor because of a non-left click. event.preventDefault(); } - if (event.ctrlKey || event.shiftKey) { + if ( + (event.ctrlKey && !isMac) || + event.shiftKey || + (event.metaKey && isMac) + ) { this.parent.toggleSelected(this); } else { this.parent.setSelected(this); diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 36563d799..77b433dc7 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -433,7 +433,7 @@ class AnnotationEditorUIManager { ], AnnotationEditorUIManager.prototype.delete, ], - [["Escape"], AnnotationEditorUIManager.prototype.unselectAll], + [["Escape", "mac+Escape"], AnnotationEditorUIManager.prototype.unselectAll], ]); constructor(container, eventBus) {