MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DispatchHoverEvent

Function DispatchHoverEvent

src/window.cpp:792–811  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

790 * @param y Y coordinate of the click.
791 */
792static void DispatchHoverEvent(Window *w, int x, int y)
793{
794 NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
795
796 /* No widget to handle */
797 if (wid == nullptr) return;
798
799 Point pt = { x, y };
800
801 /* Show the tooltip if there is any */
802 if (!w->OnTooltip(pt, wid->GetIndex(), TCC_HOVER) && wid->GetToolTip() != STR_NULL) {
803 GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TCC_HOVER);
804 return;
805 }
806
807 /* Widget has no index, so the window is not interested in it. */
808 if (wid->GetIndex() < 0) return;
809
810 w->OnHover(pt, wid->GetIndex());
811}
812
813/**
814 * Dispatch the mousewheel-action to the window.

Callers 1

MouseLoopFunction · 0.85

Calls 7

GuiShowTooltipsFunction · 0.85
GetToolTipMethod · 0.80
OnHoverMethod · 0.80
GetEncodedStringFunction · 0.70
GetWidgetFromPosMethod · 0.45
OnTooltipMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected