Merge pull request #15218 from calixteman/mac_ctrl

[Editor] Fix few keyboard shortcuts on mac
This commit is contained in:
calixteman 2022-07-25 09:50:45 +02:00 committed by GitHub
commit 14a8b819dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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);

View File

@ -433,7 +433,7 @@ class AnnotationEditorUIManager {
],
AnnotationEditorUIManager.prototype.delete,
],
[["Escape"], AnnotationEditorUIManager.prototype.unselectAll],
[["Escape", "mac+Escape"], AnnotationEditorUIManager.prototype.unselectAll],
]);
constructor(container, eventBus) {