Jump to content

mousePointer.button changes from MIDDLE_BUTTON to LEFT_BUTTON on drag


Kadith
 Share

Recommended Posts

First time posting here so let me know if I've made any mistakes!

I'm currently using Phaser 2.6.2 and am attempting to implement a panning feature using the middle mouse button. I found that when the mouseMove event is called that game.input.mousePointer.button variable is forced to be LEFT_BUTTON.

I've made this small example in Phaser's sandbox. As soon as the cursor enters the stage it thinks LEFT_BUTTON is down. If you hold the middle mouse button down without moving the mouse it will register MIDDLE_BUTTON as being down until the mouse is moved again.

Hopefully it's just something I'm doing wrong but if not is there anyway to get the current state of the mouse button during a mouse move other than using game.input.mousePointer.button? 

Thanks!

-Kadith

Link to comment
Share on other sites

I see the same behavior in the latest version of Phaser CE, as well as in the Phaser input example (https://phaser.io/examples/v2/input/mouse-buttons) in the latest versions of both Chrome and Firefox.

Seems appropriate to file a bug for investigation ☺️

Here's more information on how to do so: https://github.com/photonstorm/phaser-ce/blob/master/.github/CONTRIBUTING.md#reporting-issues

In the meantime, you can use the middle mouse button's onDown and onUp events to set a variable that tracks whether the button is down. Here's an example: https://codepen.io/giniwren/pen/LrwjYZ

Link to comment
Share on other sites

6 hours ago, samme said:

Pointer#button isn't actually the button that's currently down, it's the button associated with the last mouse event.

Shouldn't the last event still have it registered as down in that case if the button hasn't released it? Or does that only get set when the button is pressed?

 

Quote

Use mousePointer.middleButton.isDown instead.

Worked like a charm thanks!

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...