How to figure out if Right Mouse Button is pressed?

Hello Everyone

 

Like the title sayed i Want to know how i can figure out that the RMB is beeing pressed. The Manuel says that "TouchInput.isCancelled" do this but

it doesn't work.

 

I tryed it like this

 

Scene_Equip.prototype.update = function() { Scene_MenuBase.prototype.update.call(this); if (TouchInput.isCancelled()) { console.log("Right Mouse button was Clicked"); } else if (TouchInput.isPressed()) { console.log("Left Mouse button was Clicked"); }};Only The log for the left Mouse Button is printet out but nothing happens if i press the right Button.
If I had to guess, I'd say because in Scene_MenuBase's update, which you call via "Scene_MenuBase.prototype.update.call(this);", it has the command window check for the right button being clicked, and if it is, then the scene is returned to the map. If you want to add some functionality that would involve not closing the scene immediately at right click, you'll have to change the popScene function.

While not obvious at first, the scene is controlled by the command window. If the command window is active and it receives a 'cancel' input (meaning Input.isTriggered("cancel") or TouchInput.isCancelled()), then it will close the scene. Since this is handled by the window and no the update function, the update function may not work like you're thinking it will.
I was messing with mouse features earlier and here's what I got after just wanting to detect what was being hit. This willl break your game if copied directly but will show results in the debug window.

Of course, this can re-written to work any way you wish, I have it working in one of my scripts. (I borrowed Scene_Base just for quick testing)

var Mouse = new Point();function _onMouseDown(event) { Mouse._selectedindex = event.button;}document.addEventListener('mousedown', _onMouseDown);Scene_Base.prototype.update = function() { if (Mouse._selectedindex == 0) { console.log("Left Mouse Button Clicked"); } if (Mouse._selectedindex == 1) { console.log("Middle Mouse Button Clicked"); } if (Mouse._selectedindex == 2) { console.log("Right Mouse Button Clicked"); }Mouse._selectedindex = null;}Hope this helps a bit.
I was messing with mouse features earlier and here's what I got after just wanting to detect what was being hit. This willl break your game if copied directly but will show results in the debug window.

Of course, this can re-written to work any way you wish, I have it working in one of my scripts. (I borrowed Scene_Base just for quick testing)

var Mouse = new Point();function _onMouseDown(event) { Mouse._selectedindex = event.button;}document.addEventListener('mousedown', _onMouseDown);Scene_Base.prototype.update = function() { if (Mouse._selectedindex == 0) { console.log("Left Mouse Button Clicked"); } if (Mouse._selectedindex == 1) { console.log("Middle Mouse Button Clicked"); } if (Mouse._selectedindex == 2) { console.log("Right Mouse Button Clicked"); }Mouse._selectedindex = null;}Hope this helps a bit.
Thank you alot for this it rly works well 🙂 .

Original thread: https://forums.rpgmakerweb.com/threads/how-to-figure-out-if-right-mouse-button-is-pressed.48878/