1
0
Fork 0

(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.

release/1.1
rubidium 2010-07-14 17:36:27 +00:00
parent fa3d9d04d3
commit 0e078670b7
4 changed files with 52 additions and 45 deletions

View File

@ -793,9 +793,9 @@ struct DepotWindow : Window {
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str); DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str);
} }
virtual void OnRightClick(Point pt, int widget) virtual bool OnRightClick(Point pt, int widget)
{ {
if (widget != DEPOT_WIDGET_MATRIX) return; if (widget != DEPOT_WIDGET_MATRIX) return false;
GetDepotVehiclePtData gdvp = { NULL, NULL }; GetDepotVehiclePtData gdvp = { NULL, NULL };
const Vehicle *v = NULL; const Vehicle *v = NULL;
@ -804,7 +804,8 @@ struct DepotWindow : Window {
if (this->type == VEH_TRAIN) v = gdvp.wagon; if (this->type == VEH_TRAIN) v = gdvp.wagon;
if (v != NULL && mode == MODE_DRAG_VEHICLE) { if (v == NULL || mode != MODE_DRAG_VEHICLE) return false;
CargoArray capacity, loaded; CargoArray capacity, loaded;
/* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */ /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */
@ -844,7 +845,8 @@ struct DepotWindow : Window {
args[0] = (whole_chain ? num : v->engine_type); args[0] = (whole_chain ? num : v->engine_type);
args[1] = (uint64)(size_t)details; args[1] = (uint64)(size_t)details;
GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK); GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
}
return true;
} }
virtual void OnPlaceObject(Point pt, TileIndex tile) virtual void OnPlaceObject(Point pt, TileIndex tile)

View File

@ -1258,12 +1258,12 @@ public:
} }
} }
virtual void OnRightClick(Point pt, int widget) virtual bool OnRightClick(Point pt, int widget)
{ {
if (widget == SM_WIDGET_MAP) { if (widget != SM_WIDGET_MAP || _scrolling_viewport) return false;
if (_scrolling_viewport) return;
_scrolling_viewport = true; _scrolling_viewport = true;
} return true;
} }
virtual void OnMouseWheel(int wheel) virtual void OnMouseWheel(int wheel)

View File

@ -383,12 +383,15 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
static void DispatchRightClickEvent(Window *w, int x, int y) static void DispatchRightClickEvent(Window *w, int x, int y)
{ {
NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y); NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
if (wid == NULL) return;
/* No widget to handle, or the window is not interested in it. */ /* No widget to handle, or the window is not interested in it. */
if (wid == NULL || wid->index < 0) return; if (wid->index >= 0) {
Point pt = { x, y }; Point pt = { x, y };
w->OnRightClick(pt, wid->index); if (w->OnRightClick(pt, wid->index)) return;
}
if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
} }
/** /**

View File

@ -654,8 +654,10 @@ public:
* A click with the right mouse button has been made on the window. * A click with the right mouse button has been made on the window.
* @param pt the point inside the window that has been clicked. * @param pt the point inside the window that has been clicked.
* @param widget the clicked widget. * @param widget the clicked widget.
* @return true if the click was actually handled, i.e. do not show a
* tooltip if tooltip-on-right-click is enabled.
*/ */
virtual void OnRightClick(Point pt, int widget) {} virtual bool OnRightClick(Point pt, int widget) { return false; }
/** /**
* The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip. * The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip.