Skip to content

fix: mouseEvent accepts eventUsed but never checks or returns it #11

@TheCodingDad-TisonK

Description

@TheCodingDad-TisonK

Problem

The taxMouseHandler in main.lua accepts eventUsed in its signature but ignores it.

Current code (main.lua ~line 538):

function taxMouseHandler:mouseEvent(posX, posY, isDown, isUp, button, eventUsed)
    if taxHUD then taxHUD:onMouseEvent(posX, posY, isDown, isUp, button) end
end

eventUsed is declared but never checked or returned. This means:

  1. Events consumed by a vehicle camera or another listener still reach the tax HUD
  2. When the HUD consumes an event, downstream listeners are never notified

TaxHUD:onMouseEvent (src/ui/TaxHUD.lua ~line 252) also has the same gap — no eventUsed parameter, no return value.

Impact

In vehicles, the camera system consumes RMB events before mod listeners run. With no guard, the tax HUD can respond to those already-consumed events and trigger edit mode with a stale cursor position.

Fix

main.lua:

function taxMouseHandler:mouseEvent(posX, posY, isDown, isUp, button, eventUsed)
    if not eventUsed and taxHUD then
        eventUsed = taxHUD:onMouseEvent(posX, posY, isDown, isUp, button, eventUsed) or eventUsed
    end
    return eventUsed
end

TaxHUD:onMouseEvent:

function TaxHUD:onMouseEvent(posX, posY, isDown, isUp, button, eventUsed)
    -- ... existing logic ...
    -- return true when consuming, false otherwise
end

Use Input.MOUSE_BUTTON_RIGHT (= 3) and Input.MOUSE_BUTTON_LEFT (= 1) constants — confirmed in LUADOC.

Reference

Fixed in FS25_SoilFertilizer commit d5b8f31 (issue TheCodingDad-TisonK/FS25_SoilFertilizer#130).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguser-repliedUser is awaiting response

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions