Skip to content

Commit

Permalink
Merge pull request mozilla#15218 from calixteman/mac_ctrl
Browse files Browse the repository at this point in the history
[Editor] Fix few keyboard shortcuts on mac
  • Loading branch information
calixteman authored Jul 25, 2022
2 parents 9cc5260 + 85f3e23 commit 14a8b81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class AnnotationEditorUIManager {
],
AnnotationEditorUIManager.prototype.delete,
],
[["Escape"], AnnotationEditorUIManager.prototype.unselectAll],
[["Escape", "mac+Escape"], AnnotationEditorUIManager.prototype.unselectAll],
]);

constructor(container, eventBus) {
Expand Down

0 comments on commit 14a8b81

Please sign in to comment.