Differential D1703 Diff 11331 binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/Controls/SearchBox.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/Controls/SearchBox.js
- This file was added.
MapBrowserPageControls.SearchBox = class extends MapBrowserFilter | |||||
{ | |||||
constructor(mapBrowserPage, gridBrowser, setupWindow) | |||||
{ | |||||
super(); | |||||
this.mapBrowserPage = mapBrowserPage; | |||||
this.gridBrowser = gridBrowser; | |||||
this.mapCache = setupWindow.controls.mapCache; | |||||
this.control = Engine.GetGUIObjectByName("mapsSearchBox"); | |||||
this.control.onTab = this.gridBrowser.nextPage.bind(this.gridBrowser); | |||||
this.control.onPress = this.onPress.bind(this); | |||||
this.control.onTextEdit = this.onTextEdit.bind(this); | |||||
this.label = Engine.GetGUIObjectByName("mapsSearchBoxLabel"); | |||||
this.resizeLabel(); | |||||
mapBrowserPage.registerOpenPageHandler(this.onOpenPage.bind(this)); | |||||
mapBrowserPage.registerClosePageHandler(this.onClosePage.bind(this)); | |||||
} | |||||
onOpenPage() | |||||
{ | |||||
// setTimeout avoids having the hotkey key inserted into the input text | |||||
setTimeout(() => | |||||
{ | |||||
this.control.focus(); | |||||
// focus resets cursor position | |||||
this.control.buffer_position = this.control.caption.length; | |||||
}, 0); | |||||
} | |||||
onClosePage() | |||||
{ | |||||
this.control.blur(); | |||||
} | |||||
onTextEdit() | |||||
{ | |||||
this.gridBrowser.updateMapList(); | |||||
this.gridBrowser.goToPage(0); | |||||
} | |||||
onPress() | |||||
{ | |||||
this.gridBrowser.setSelectedIndex(0); | |||||
this.gridBrowser.submitMapSelection(); | |||||
this.mapBrowserPage.closePage(); | |||||
} | |||||
getFilterText() | |||||
{ | |||||
return this.control.caption.trim(); | |||||
} | |||||
}; |
Wildfire Games · Phabricator