1
0
mirror of https://github.com/BoostIo/Boostnote synced 2026-07-12 07:53:11 +00:00

実装 - Hotkey

This commit is contained in:
Rokt33r
2015-08-22 23:57:37 +09:00
parent b88d5cfb06
commit da066fe694
24 changed files with 378 additions and 61 deletions
+15 -1
View File
@@ -21,7 +21,21 @@ module.exports = React.createClass({
}
},
componentDidMount: function () {
React.findDOMNode(this.refs.search).focus()
var search = React.findDOMNode(this.refs.search)
search.addEventListener('keydown', this.handleSearchKeyDown)
},
componentWillUnmount: function () {
var search = React.findDOMNode(this.refs.search)
search.removeEventListener('keydown', this.handleSearchKeyDown)
},
handleSearchKeyDown: function (e) {
if (e.keyCode === 38 || e.keyCode === 40) {
var search = React.findDOMNode(this.refs.search)
search.blur()
}
if (e.keyCode !== 27 && (e.keyCode !== 13 || !e.metaKey)) {
e.stopPropagation()
}
},
openPlanetSettingModal: function () {
this.openModal(PlanetSettingModal, {planet: this.props.currentPlanet})