1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

refs #226 Adds focus to search shortcut to main-menu

This commit is contained in:
asmsuechan
2017-01-14 00:49:54 +09:00
parent e8e05b20cd
commit 2468c8311f
2 changed files with 21 additions and 0 deletions

View File

@@ -24,14 +24,20 @@ class TopBar extends React.Component {
this.newNoteHandler = () => { this.newNoteHandler = () => {
this.handleNewPostButtonClick() this.handleNewPostButtonClick()
} }
this.focusSearchHandler = () => {
this.handleFocusSearch()
}
} }
componentDidMount () { componentDidMount () {
ee.on('top:new-note', this.newNoteHandler) ee.on('top:new-note', this.newNoteHandler)
ee.on('top:focus-search', this.focusSearchHandler)
} }
componentWillUnmount () { componentWillUnmount () {
ee.off('top:new-note', this.newNoteHandler) ee.off('top:new-note', this.newNoteHandler)
ee.off('top:focus-search', this.focusSearchHandler)
} }
handleNewPostButtonClick (e) { handleNewPostButtonClick (e) {
@@ -244,6 +250,10 @@ class TopBar extends React.Component {
}) })
} }
handleFocusSearch () {
this.refs.search.childNodes[0].focus()
}
render () { render () {
let { config, style, data } = this.props let { config, style, data } = this.props
let searchOptionList = this.getOptions() let searchOptionList = this.getOptions()
@@ -287,6 +297,7 @@ class TopBar extends React.Component {
onChange={(e) => this.handleSearchChange(e)} onChange={(e) => this.handleSearchChange(e)}
placeholder='Search' placeholder='Search'
type='text' type='text'
id='Search'
/> />
{this.state.searchPopupOpen && {this.state.searchPopupOpen &&
<div styleName='control-search-optionList'> <div styleName='control-search-optionList'>

View File

@@ -143,6 +143,16 @@ var view = {
click: function () { click: function () {
BrowserWindow.getFocusedWindow().toggleDevTools() BrowserWindow.getFocusedWindow().toggleDevTools()
} }
},
{
type: 'separator'
},
{
label: 'Focus Search',
accelerator: 'Control + S',
click: function () {
mainWindow.webContents.send('top:focus-search')
}
} }
] ]
} }