Skip to content

Commit

Permalink
fix: add event modifiers for mpl 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhi committed Feb 15, 2023
1 parent 31ae91d commit 0d12cad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ export class MPLCanvasView extends DOMWidgetView {
y: y,
button: event.button,
step: event.step,
modifiers: utils.getModifiers(event),
guiEvent: utils.get_simple_keys(event),
});
};
Expand Down
17 changes: 17 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@ export function getContext(canvas: HTMLCanvasElement) {
}
return context;
}

export function getModifiers(event: MouseEvent) {
const mods = [];
if (event.ctrlKey) {
mods.push('ctrl');
}
if (event.altKey) {
mods.push('alt');
}
if (event.shiftKey) {
mods.push('shift');
}
if (event.metaKey) {
mods.push('meta');
}
return mods;
}

0 comments on commit 0d12cad

Please sign in to comment.