Codechange: Add utility function for whether the focused window is a console

This commit is contained in:
Jonathan G Rennison 2019-11-04 18:10:09 +00:00 committed by Charles Pigott
parent 81f159434d
commit 1dba06656d
2 changed files with 10 additions and 0 deletions

View File

@ -466,6 +466,15 @@ bool EditBoxInGlobalFocus()
return _focused_window->nested_focus != nullptr && _focused_window->nested_focus->type == WWT_EDITBOX; return _focused_window->nested_focus != nullptr && _focused_window->nested_focus->type == WWT_EDITBOX;
} }
/**
* Check if a console is focused.
* @return returns true if the focused window is a console, else false
*/
bool FocusedWindowIsConsole()
{
return _focused_window && _focused_window->window_class == WC_CONSOLE;
}
/** /**
* Makes no widget on this window have focus. The function however doesn't change which window has focus. * Makes no widget on this window have focus. The function however doesn't change which window has focus.
*/ */

View File

@ -55,6 +55,7 @@ void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true);
void DeleteWindowByClass(WindowClass cls); void DeleteWindowByClass(WindowClass cls);
bool EditBoxInGlobalFocus(); bool EditBoxInGlobalFocus();
bool FocusedWindowIsConsole();
Point GetCaretPosition(); Point GetCaretPosition();
#endif /* WINDOW_FUNC_H */ #endif /* WINDOW_FUNC_H */