MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetFocusedWindow

Function SetFocusedWindow

src/window.cpp:423–442  ·  view source on GitHub ↗

* Set the window that has the focus * @param w The window to set the focus on */

Source from the content-addressed store, hash-verified

421 * @param w The window to set the focus on
422 */
423void SetFocusedWindow(Window *w)
424{
425 if (_focused_window == w) return;
426
427 /* Don't focus a tooltip */
428 if (w != nullptr && w->window_class == WC_TOOLTIPS) return;
429
430 /* Invalidate focused widget */
431 if (_focused_window != nullptr) {
432 if (_focused_window->nested_focus != nullptr) _focused_window->nested_focus->SetDirty(_focused_window);
433 }
434
435 /* Remember which window was previously focused */
436 Window *old_focused = _focused_window;
437 _focused_window = w;
438
439 /* So we can inform it that it lost focus */
440 if (old_focused != nullptr) old_focused->OnFocusLost(false);
441 if (_focused_window != nullptr) _focused_window->OnFocus();
442}
443
444/**
445 * Check if an edit box is in global focus. That is if focused window

Callers 5

OnHotkeyMethod · 0.85
DispatchLeftClickEventFunction · 0.85
InitializeDataMethod · 0.85
ShowQueryFunction · 0.85
OnHotkeyMethod · 0.85

Calls 3

SetDirtyMethod · 0.45
OnFocusLostMethod · 0.45
OnFocusMethod · 0.45

Tested by

no test coverage detected