summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-07-11 10:58:55 +0000
committerterkhen <terkhen@openttd.org>2010-07-11 10:58:55 +0000
commit10fbb87823dd689844c93ce8b0d43a5098acdba9 (patch)
treefb217ff4f1631792b62f9a9879b774af8f018c5f /src/window.cpp
parent51e6cb0a70d0e4076a91305d308f3f467aa950df (diff)
downloadopenttd-10fbb87823dd689844c93ce8b0d43a5098acdba9.tar.xz
(svn r20120) -Feature [FS#3913]: Tooltips are shown by hovering the mouse over a widget instead of by right clicking on it.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 69fccf9d3..d34f138b6 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -384,6 +384,23 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
{
NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
+ /* No widget to handle, or the window is not interested in it. */
+ if (wid == NULL || wid->index < 0) return;
+
+ Point pt = { x, y };
+ w->OnRightClick(pt, wid->index);
+}
+
+/**
+ * Dispatch hover of the mouse over a window.
+ * @param w Window to dispatch event in.
+ * @param x X coordinate of the click.
+ * @param y Y coordinate of the click.
+ */
+static void DispatchHoverEvent(Window *w, int x, int y)
+{
+ NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
+
/* No widget to handle */
if (wid == NULL) return;
@@ -392,12 +409,6 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
GuiShowTooltips(wid->tool_tip);
return;
}
-
- /* Widget has no index, so the window is not interested in it. */
- if (wid->index < 0) return;
-
- Point pt = { x, y };
- w->OnRightClick(pt, wid->index);
}
/**
@@ -2178,6 +2189,8 @@ static void MouseLoop(MouseClick click, int mousewheel)
/* fallthough */
case MC_RIGHT: DispatchRightClickEvent(w, x - w->left, y - w->top); break;
+
+ case MC_HOVER: DispatchHoverEvent(w, x - w->left, y - w->top); break;
}
}
}