* A hotkey has been pressed. * @param hotkey Hotkey index, by default a widget index of a button or editbox. * @return #ES_HANDLED if the key press has been handled, and the hotkey is not unavailable for some reason. */
| 570 | * @return #ES_HANDLED if the key press has been handled, and the hotkey is not unavailable for some reason. |
| 571 | */ |
| 572 | EventState Window::OnHotkey(int hotkey) |
| 573 | { |
| 574 | if (hotkey < 0) return ES_NOT_HANDLED; |
| 575 | |
| 576 | NWidgetCore *nw = this->GetWidget<NWidgetCore>(hotkey); |
| 577 | if (nw == nullptr || nw->IsDisabled()) return ES_NOT_HANDLED; |
| 578 | |
| 579 | if (nw->type == WWT_EDITBOX) { |
| 580 | if (this->IsShaded()) return ES_NOT_HANDLED; |
| 581 | |
| 582 | /* Focus editbox */ |
| 583 | this->SetFocusedWidget(hotkey); |
| 584 | SetFocusedWindow(this); |
| 585 | } else { |
| 586 | /* Click button */ |
| 587 | this->OnClick(Point(), hotkey, 1); |
| 588 | } |
| 589 | return ES_HANDLED; |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Do all things to make a button look clicked and mark it to be |
no test coverage detected