From b2d4adf5b968e1c52096440f574b4169eb3a1672 Mon Sep 17 00:00:00 2001
From: notoraptor <notoraptor@users.noreply.github.com>
Date: Thu, 25 Jul 2019 16:34:10 -0400
Subject: 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.
---
 diplomacy/web/src/gui/forms/select_via_form.jsx | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'diplomacy/web/src/gui/forms/select_via_form.jsx')

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>
         );
-- 
cgit v1.2.3

