From 0d12cad260fcce6f12abb0b877ff48ebca630513 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Wed, 15 Feb 2023 10:12:03 -0500 Subject: [PATCH] fix: add event modifiers for mpl 3.7 --- src/mpl_widget.ts | 1 + src/utils.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/mpl_widget.ts b/src/mpl_widget.ts index 7e839f92..7aa7d76c 100644 --- a/src/mpl_widget.ts +++ b/src/mpl_widget.ts @@ -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), }); }; diff --git a/src/utils.ts b/src/utils.ts index 63444298..7705f5e6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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; +}