Skip to content

ctx.SetScale() can change the position of a click mid-frame #40

@venning

Description

@venning

(This is really minor for me, but maybe indicates something you'd like to know about.)

I have a couple checkboxes in my UI that allow me to change the screen density between 1x and 2x ("Retina") for testing. I do that by adjusting the values that game.Layout() returns. When doing this, I also change debugui's scale at the same time via ctx.SetScale() to maintain consistent UI scaling.

I noticed that when doing this, the position of the click that caused the event to trigger also gets "rescaled" to a different position and debugui will re-interpret that position and possibly infer another click if that position happens to be over another debugui element that accepts clicks (buttons, checkboxes).

Meaning, I click the "2x" checkbox to rescale while at cursor position (x, y) and the UI does so but also clicks a different button that was corresponding to cursor position (x/2, y/2) before the scale change.

The fix is simple: I delay the call to ctx.SetScale() until the next frame, when there won't be a click to misinterpret.

I don't know if this matters all that much, but I just wanted to note it.

(Really appreciating debugui. It's been the single biggest improvement in my development since Ebitengine itself.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions