Kadith Posted July 4, 2018 Share Posted July 4, 2018 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 More sharing options...
GiniWren Posted July 7, 2018 Share Posted July 7, 2018 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 Kadith 1 Link to comment Share on other sites More sharing options...
samme Posted July 8, 2018 Share Posted July 8, 2018 Pointer#button isn't actually the button that's currently down, it's the button associated with the last mouse event. Use mousePointer.middleButton.isDown instead. In the latest Phaser CE, debug.inputInfo(…) will show the three button states. https://codepen.io/samme/pen/gKqgbB Kadith 1 Link to comment Share on other sites More sharing options...
Kadith Posted July 8, 2018 Author Share Posted July 8, 2018 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 More sharing options...
samme Posted July 9, 2018 Share Posted July 9, 2018 I think right now Phaser updates Pointer#button for all mouse events, not just mouseup/mousedown. And browsers report button=0, also identical to LEFT_BUTTON, for other mouse events. Link to comment Share on other sites More sharing options...
Kadith Posted July 11, 2018 Author Share Posted July 11, 2018 If it's the browser then guess there's not much they can do about it (at least not easily). Checking the mousePointer directly is working great though so thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts