Changeset - r28308:9bb629561f7c
[Not reviewed]
master
0 1 0
Finn Willard - 18 months ago 2023-06-18 00:51:10
finn.willard@gmail.com
Add: Hotkey to focus industry directory filter box

Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
1 file changed with 24 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/industry_gui.cpp
Show inline comments
 
@@ -44,6 +44,7 @@
 
#include "stringfilter_type.h"
 
#include "timer/timer.h"
 
#include "timer/timer_window.h"
 
#include "hotkeys.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -1299,7 +1300,10 @@ static bool CDECL CargoFilter(const Indu
 

	
 
static GUIIndustryList::FilterFunction * const _filter_funcs[] = { &CargoFilter };
 

	
 

	
 
/** Enum referring to the Hotkeys in the industry directory window */
 
enum IndustryDirectoryHotkeys {
 
	IDHK_FOCUS_FILTER_BOX, ///< Focus the filter box
 
};
 
/**
 
 * The list of industries.
 
 */
 
@@ -1864,6 +1868,23 @@ public:
 
				break;
 
		}
 
	}
 

	
 
	EventState OnHotkey(int hotkey) override
 
	{
 
		switch (hotkey) {
 
			case IDHK_FOCUS_FILTER_BOX:
 
				this->SetFocusedWidget(WID_ID_FILTER);
 
				SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
 
				break;
 
			default:
 
				return ES_NOT_HANDLED;
 
		}
 
		return ES_HANDLED;
 
	}
 

	
 
	static inline HotkeyList hotkeys {"industrydirectory", {
 
		Hotkey('F', "focus_filter_box", IDHK_FOCUS_FILTER_BOX),
 
	}};
 
};
 

	
 
Listing IndustryDirectoryWindow::last_sorting = {false, 0};
 
@@ -1893,7 +1914,8 @@ static WindowDesc _industry_directory_de
 
	WDP_AUTO, "list_industries", 428, 190,
 
	WC_INDUSTRY_DIRECTORY, WC_NONE,
 
	0,
 
	std::begin(_nested_industry_directory_widgets), std::end(_nested_industry_directory_widgets)
 
	std::begin(_nested_industry_directory_widgets), std::end(_nested_industry_directory_widgets),
 
	&IndustryDirectoryWindow::hotkeys
 
);
 

	
 
void ShowIndustryDirectory()
0 comments (0 inline, 0 general)