add dialog keyboard shortcuts.

This commit is contained in:
Matthew Hodgson 2016-09-16 02:26:17 +01:00
parent eeb01563f8
commit 8519756c8c
2 changed files with 23 additions and 2 deletions

View file

@ -49,9 +49,17 @@ module.exports = React.createClass({
};
},
onKeyDown: function(e) {
if (e.keyCode === 27) { // escape
e.stopPropagation();
e.preventDefault();
this.props.onFinished(false);
}
},
render: function() {
return (
<div className="mx_ErrorDialog">
<div className="mx_ErrorDialog" onKeyDown={ this.onKeyDown }>
<div className="mx_Dialog_title">
{this.props.title}
</div>

View file

@ -46,9 +46,22 @@ module.exports = React.createClass({
this.props.onFinished(false);
},
onKeyDown: function(e) {
if (e.keyCode === 27) { // escape
e.stopPropagation();
e.preventDefault();
this.props.onFinished(false);
}
else if (e.keyCode === 13) { // enter
e.stopPropagation();
e.preventDefault();
this.props.onFinished(true);
}
},
render: function() {
return (
<div className="mx_QuestionDialog">
<div className="mx_QuestionDialog" onKeyDown={ this.onKeyDown }>
<div className="mx_Dialog_title">
{this.props.title}
</div>