diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 4a04f65262..6a28aae601 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1730,7 +1730,8 @@ public: { this->SelectClass(class_id); this->EnsureSelectedStationClassIsVisible(); - this->OnClick({}, WID_BRAS_IMAGE | (spec_id << 16), 1); + this->GetWidget(WID_BRAS_IMAGE)->GetParentWidget()->SetCurrentElement(spec_id); + this->OnClick({}, WID_BRAS_IMAGE, 1); } static HotkeyList hotkeys; @@ -2620,7 +2621,8 @@ struct BuildRailWaypointWindow : PickerWindowBase { { for (uint i = 0; i < (uint)this->list.size(); i++) { if (this->list[i] == spec_id) { - this->OnClick({}, WID_BRW_WAYPOINT | (i << 16), 1); + this->GetWidget(WID_BRW_WAYPOINT)->GetParentWidget()->SetCurrentElement(i); + this->OnClick({}, WID_BRW_WAYPOINT, 1); break; } } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 66112d7615..e05fa09421 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1747,7 +1747,8 @@ public: /* could not select class*/ return; } - this->OnClick({}, WID_BROS_IMAGE | (spec_id << 16), 1); + this->GetWidget(WID_BROS_IMAGE)->GetParentWidget()->SetCurrentElement(spec_id); + this->OnClick({}, WID_BROS_IMAGE, 1); } static HotkeyList hotkeys; @@ -2118,7 +2119,8 @@ struct BuildRoadWaypointWindow : PickerWindowBase { { for (uint i = 0; i < (uint)this->list.size(); i++) { if (this->list[i] == spec_id) { - this->OnClick({}, WID_BROW_WAYPOINT | (i << 16), 1); + this->GetWidget(WID_BROW_WAYPOINT)->GetParentWidget()->SetCurrentElement(i); + this->OnClick({}, WID_BROW_WAYPOINT, 1); break; } } diff --git a/src/widget_type.h b/src/widget_type.h index bfed36cbf6..52d57d0973 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -610,6 +610,8 @@ public: void SetScrollbar(Scrollbar *sb); int GetCurrentElement() const; + void SetCurrentElement(int current_element) { this->current_element = current_element; } + void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; void FillWidgetLookup(WidgetLookup &widget_lookup) override;