Skip to content

[p5.js 2.0 Bug Report]: mouseIsPressed stays true after losing focus, no blur reset for mouse state #8552

@avinxshKD

Description

@avinxshKD

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

No response

Web browser and version

No response

Operating system

No response

Steps to reproduce this

Hold a mouse button on the canvas, alt-tab away, release the button, come back. mouseIsPressed is still true.

keyboard.js at least has _onblur (incomplete, see #8540). mouse.js has nothing, no blur handler at all. So mouseIsPressed and mouseButton just stay frozen at whatever they were when the window lost focus.

function draw() {
  background(220);
  text('mouseIsPressed: ' + mouseIsPressed, 20, 50);
}

Steps: hold mouse on canvas → alt-tab → release → come back → still shows true

Fix would be the same pattern as the keyboard blur fix, add an _onblur to mouse.js that resets mouseIsPressed = false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions