diff --git a/src/components/ActionButton.tsx b/src/components/ActionButton.tsx index 050b3bf4..3f7a9c13 100644 --- a/src/components/ActionButton.tsx +++ b/src/components/ActionButton.tsx @@ -1,7 +1,9 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { Button, Intent, Position, Tooltip } from '@blueprintjs/core'; +import { Button, Hotkey, Hotkeys, Intent, Position, Tooltip } from '@blueprintjs/core'; +// importing this way due to https://github.com/palantir/blueprint/issues/3604 +import { HotkeysTarget } from '@blueprintjs/core/lib/esnext/components/hotkeys/hotkeysTarget'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; import { TooltipId } from './button-i18n'; @@ -10,6 +12,8 @@ import en from './button-i18n.en.json'; export interface ActionButtonProps { /** A unique id for each instance. */ readonly id: string; + /** Keyboard shortcut. */ + readonly keyboardShortcut?: string; /** Tooltip text that appears when hovering over the button. */ readonly tooltip: TooltipId; /** Icon shown on the button. */ @@ -22,14 +26,19 @@ export interface ActionButtonProps { type Props = ActionButtonProps & WithI18nProps; +@HotkeysTarget class ActionButton extends React.Component { + private buttonRef: React.RefObject