Skip to content

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

@TheCodingDad-TisonK

Description

@TheCodingDad-TisonK

Problem

The incomeMouseHandler in src/main.lua accepts eventUsed in its signature but does not check it before processing and does not return it.

Current code (src/main.lua ~line 81):

function incomeMouseHandler:mouseEvent(posX, posY, isDown, isUp, button, eventUsed)
    if im and im.incomeHUD then
        im.incomeHUD:onMouseEvent(posX, posY, isDown, isUp, button)
    end
end

The parameter is declared but silently ignored. This means:

  1. Events already consumed by a vehicle camera or another listener still trigger HUD processing
  2. When the HUD does consume an event, the flag is never passed back to the engine

Impact

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

Fix

function incomeMouseHandler:mouseEvent(posX, posY, isDown, isUp, button, eventUsed)
    if not eventUsed and im and im.incomeHUD then
        eventUsed = im.incomeHUD:onMouseEvent(posX, posY, isDown, isUp, button, eventUsed) or eventUsed
    end
    return eventUsed
end

IncomeHUD:onMouseEvent also needs to accept eventUsed and return true when it consumes an event, false otherwise.

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