aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/web/src/gui/forms/select_via_form.jsx
diff options
context:
space:
mode:
authornotoraptor <notoraptor@users.noreply.github.com>2019-07-25 16:34:10 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-07-25 16:34:10 -0400
commitb2d4adf5b968e1c52096440f574b4169eb3a1672 (patch)
tree8b2cf2a88bb8003d995f907bf73ca05068c4cb65 /diplomacy/web/src/gui/forms/select_via_form.jsx
parent48ee1a065debde5027fc17e49144d348258dc5e4 (diff)
Add select via shortcut (#61)
- [web][select via dialog] Add shortcuts M and V. - [web][select via dialog] Asynchronously handle "select via" method, so that shortcut callback can continue to run (and then set its state) without waiting for callback return. This should help to prevent React from updating an unmounted shortcut component.
Diffstat (limited to 'diplomacy/web/src/gui/forms/select_via_form.jsx')
-rw-r--r--diplomacy/web/src/gui/forms/select_via_form.jsx3
1 files changed, 3 insertions, 0 deletions
diff --git a/diplomacy/web/src/gui/forms/select_via_form.jsx b/diplomacy/web/src/gui/forms/select_via_form.jsx
index 8b340af..c0f13a5 100644
--- a/diplomacy/web/src/gui/forms/select_via_form.jsx
+++ b/diplomacy/web/src/gui/forms/select_via_form.jsx
@@ -18,6 +18,7 @@ import React from "react";
import PropTypes from "prop-types";
import {Button} from "../components/button";
import {FancyBox} from "../components/fancyBox";
+const HotKey = require('react-shortcut');
export class SelectViaForm extends React.Component {
render() {
@@ -27,6 +28,8 @@ export class SelectViaForm extends React.Component {
<div>
<Button title={'regular move (M)'} large={true} onClick={() => this.props.onSelect('M')}/>
<Button title={'move via (V)'} large={true} onClick={() => this.props.onSelect('V')}/>
+ <HotKey keys={['m']} onKeysCoincide={() => this.props.onSelect('M')}/>
+ <HotKey keys={['v']} onKeysCoincide={() => this.props.onSelect('V')}/>
</div>
</FancyBox>
);