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

Function DispatchRightClickEvent

src/window.cpp:763–784  ·  view source on GitHub ↗

* Dispatch right mouse-button click in 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

761 * @param y Y coordinate of the click
762 */
763static void DispatchRightClickEvent(Window *w, int x, int y)
764{
765 NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
766 if (wid == nullptr) return;
767
768 Point pt = { x, y };
769
770 /* No widget to handle, or the window is not interested in it. */
771 if (wid->GetIndex() >= 0) {
772 if (w->OnRightClick(pt, wid->GetIndex())) return;
773 }
774
775 /* Right-click close is enabled and there is a closebox. */
776 if (_settings_client.gui.right_click_wnd_close == RCC_YES && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
777 w->Close();
778 } else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && !w->flags.Test(WindowFlag::Sticky) && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
779 /* Right-click close is enabled, but excluding sticky windows. */
780 w->Close();
781 } else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) {
782 GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TCC_RIGHT_CLICK);
783 }
784}
785
786/**
787 * Dispatch hover of the mouse over a window.

Callers 1

MouseLoopFunction · 0.85

Calls 9

GuiShowTooltipsFunction · 0.85
TestMethod · 0.80
GetToolTipMethod · 0.80
GetEncodedStringFunction · 0.70
GetWidgetFromPosMethod · 0.45
GetIndexMethod · 0.45
OnRightClickMethod · 0.45
CloseMethod · 0.45
OnTooltipMethod · 0.45

Tested by

no test coverage detected