Skip to content

mouseReleased behaviour on OSX #5672

@clankill3r

Description

@clankill3r

Any Processing version, any OSX version...

This is not a processing bug, but an annoying thing of how Apple / Java deals with input.

On OSX the behaviour [ctrl] + mouseClick is used as right mouse.
If you do the following steps:

  • click with the left mouse and hold
  • press control and hold
  • release the left mouse

Then it will trigger a mouseReleased for button RIGHT while a mousePressed on button RIGHT has never happened.

So if you want to keep track of which button is pressed, you can end up with a state that is wrong.

I think the correct behaviour would be that it still triggers a mouseReleased for the LEFT button.

There is probably no way around this...

boolean mouse_left_pressed;
boolean mouse_right_pressed;

void setup() {
  size(200, 100);  
}

void draw() {
  background(0);
  fill(255);
  text("left: "+mouse_left_pressed, 50, 50);
  text("right: "+mouse_right_pressed, 50, 75);
}


public void mousePressed() {
  if (mouseButton == LEFT) mouse_left_pressed = true;
  if (mouseButton == RIGHT) mouse_right_pressed = true;
}

public void mouseReleased() {
  if (mouseButton == LEFT) mouse_left_pressed = false;
  if (mouseButton == RIGHT) mouse_right_pressed = false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions