diff --git a/newIDE/app/src/EventsSheet/SearchPanel.js b/newIDE/app/src/EventsSheet/SearchPanel.js index 3b3d68ad94..4691481ec3 100644 --- a/newIDE/app/src/EventsSheet/SearchPanel.js +++ b/newIDE/app/src/EventsSheet/SearchPanel.js @@ -31,6 +31,7 @@ type State = {| |}; export default class SearchPanel extends PureComponent { + searchTextField: ?TextField; state = { searchDirty: false, searchText: '', @@ -39,6 +40,12 @@ export default class SearchPanel extends PureComponent { searchInSelection: false, }; + focus = () => { + if (this.searchTextField) { + this.searchTextField.focus(); + } + } + launchSearch = () => { const { searchText, searchInSelection, matchCase } = this.state; this.props.onSearchInEvents({ @@ -92,6 +99,7 @@ export default class SearchPanel extends PureComponent { this.searchTextField = _searchTextField} hintText="Text to search" onChange={(e, searchText) => this.setState({ searchText, searchDirty: true })} diff --git a/newIDE/app/src/EventsSheet/index.js b/newIDE/app/src/EventsSheet/index.js index dbf89d6fcf..5cb9d3669e 100644 --- a/newIDE/app/src/EventsSheet/index.js +++ b/newIDE/app/src/EventsSheet/index.js @@ -120,6 +120,7 @@ export default class EventsSheet extends React.Component { _keyboardShortcuts: KeyboardShortcuts; _eventsTree: EventsTree; _eventSearcher: ?EventsSearcher; + _searchPanel: ?SearchPanel; eventContextMenu: ContextMenu; instructionContextMenu: ContextMenu; instructionsListContextMenu: ContextMenu; @@ -170,6 +171,7 @@ export default class EventsSheet extends React.Component { onCopy: this.copySelection, onCut: this.cutSelection, onPaste: this.pasteEventsOrInstructions, + onSearch: this._toggleSearchPanel, }); } @@ -210,16 +212,23 @@ export default class EventsSheet extends React.Component { } _toggleSearchPanel = () => { - this.setState(state => { - const show = !state.showSearchPanel; - if (!show) { - if (this._eventSearcher) this._eventSearcher.reset(); - } + this.setState( + state => { + const show = !state.showSearchPanel; + if (!show) { + if (this._eventSearcher) this._eventSearcher.reset(); + } - return { - showSearchPanel: show, - }; - }); + return { + showSearchPanel: show, + }; + }, + () => { + if (this.state.showSearchPanel && this._searchPanel) { + this._searchPanel.focus(); + } + } + ); }; addSubEvents = () => { @@ -667,7 +676,7 @@ export default class EventsSheet extends React.Component { return ( this._eventSearcher = eventSearcher} + ref={eventSearcher => (this._eventSearcher = eventSearcher)} events={events} project={project} layout={layout} @@ -717,6 +726,7 @@ export default class EventsSheet extends React.Component { /> {this.state.showSearchPanel && ( (this._searchPanel = searchPanel)} onSearchInEvents={inputs => this._searchInEvents(searchInEvents, inputs)} onReplaceInEvents={inputs => diff --git a/newIDE/app/src/UI/KeyboardShortcuts/index.js b/newIDE/app/src/UI/KeyboardShortcuts/index.js index b6537e6cf3..0bf23c48a5 100644 --- a/newIDE/app/src/UI/KeyboardShortcuts/index.js +++ b/newIDE/app/src/UI/KeyboardShortcuts/index.js @@ -14,6 +14,7 @@ const MINUS_KEY = 189; const NUMPAD_ADD = 107; const NUMPAD_SUBSTRACT = 109; const C_KEY = 67; +const F_KEY = 70; const V_KEY = 86; const X_KEY = 88; const Y_KEY = 89; @@ -29,6 +30,7 @@ export default class KeyboardShortcuts { onPaste, onUndo, onRedo, + onSearch, onZoomOut, onZoomIn, }) { @@ -41,6 +43,7 @@ export default class KeyboardShortcuts { this.onRedo = onRedo || this._noop; this.onZoomOut = onZoomOut || this._noop; this.onZoomIn = onZoomIn || this._noop; + this.onSearch = onSearch || this._noop; this.isFocused = false; this.shiftPressed = false; this.rawCtrlPressed = false; @@ -136,6 +139,9 @@ export default class KeyboardShortcuts { if (this._isControlPressed() && evt.which === Y_KEY) { this.onRedo(); } + if (this._isControlPressed() && evt.which === F_KEY) { + this.onSearch(); + } if (isMacLike()) { //Mac specific shortcuts -- zooming done differently on windows and linux