* A dropdown window associated to this window has been closed. * @param pt the point inside the window the mouse resides on after closure. * @param widget the widget (button) that the dropdown is associated with. * @param index the element in the dropdown that is selected. * @param instant_close whether the dropdown was configured to close on mouse up. */
| 284 | * @param instant_close whether the dropdown was configured to close on mouse up. |
| 285 | */ |
| 286 | void Window::OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close) |
| 287 | { |
| 288 | if (widget < 0) return; |
| 289 | |
| 290 | /* Many dropdown selections depend on the position of the main toolbar, |
| 291 | * so if it doesn't exist (e.g. the end screen has appeared), just skip the instant close behaviour. */ |
| 292 | if (instant_close && FindWindowById(WC_MAIN_TOOLBAR, 0) != nullptr) { |
| 293 | /* Send event for selected option if we're still |
| 294 | * on the parent button of the dropdown (behaviour of the dropdowns in the main toolbar). */ |
| 295 | if (GetWidgetFromPos(this, pt.x, pt.y) == widget) { |
| 296 | this->OnDropdownSelect(widget, index, click_result); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /* Raise the dropdown button */ |
| 301 | NWidgetCore *nwi2 = this->GetWidget<NWidgetCore>(widget); |
| 302 | if ((nwi2->type & WWT_MASK) == NWID_BUTTON_DROPDOWN) { |
| 303 | nwi2->disp_flags.Reset(NWidgetDisplayFlag::DropdownActive); |
| 304 | } else { |
| 305 | this->RaiseWidget(widget); |
| 306 | } |
| 307 | this->SetWidgetDirty(widget); |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Return the Scrollbar to a widget index. |
no test coverage detected