* Set the window that has the focus * @param w The window to set the focus on */
| 421 | * @param w The window to set the focus on |
| 422 | */ |
| 423 | void 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 |
no test coverage detected