Skip to content

Unexpected mouseConstraint behavior on mouse leaving end re-entering p5 canvas creates  #1327

@alexf77

Description

@alexf77

Using p5 for rendering, I discovered a weird behavior:

Screen.Recording.2025-01-03.at.10.00.31.mov
  • clicking and dragging a body
  • mouse leaves canvas without releasing button
  • body is detached from mouse and falls as expected
  • while mouse is outside canvas, button is released
  • mouse reenters canvas
  • when mouse is hovering over the previously dragged body, the body becomes attached to mouse
  • on mousedown it is released

I found this solution with the help of Copilot:

canvas.elt.addEventListener("mouseout", () => {
    canvasMouse.button = -1;
  });

for a newbie like me it would be helpful if this were mentioned in the docs, or perhaps even default behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions