1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-31 08:04:36 +01:00

Codechange: Add OnClick handler for dropdown items.

This allows each dropdown item to indicate if something different should happen depending on where in the item was clicked.
This commit is contained in:
Peter Nelson
2025-05-23 17:44:17 +01:00
committed by Peter Nelson
parent 04e07dff84
commit 984d864c72
29 changed files with 95 additions and 55 deletions

View File

@@ -282,7 +282,7 @@ bool Window::IsWidgetHighlighted(WidgetID widget_index) const
* @param index the element in the dropdown that is selected.
* @param instant_close whether the dropdown was configured to close on mouse up.
*/
void Window::OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
void Window::OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close)
{
if (widget < 0) return;
@@ -290,7 +290,7 @@ void Window::OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_
/* Send event for selected option if we're still
* on the parent button of the dropdown (behaviour of the dropdowns in the main toolbar). */
if (GetWidgetFromPos(this, pt.x, pt.y) == widget) {
this->OnDropdownSelect(widget, index);
this->OnDropdownSelect(widget, index, click_result);
}
}