TouchInput._onMouseDown

Gyldstrand

Veteran
Veteran
Joined
Oct 16, 2014
Messages
76
Reaction score
4
TouchInput._onMouseDown = function(event) { if (event.button === 0) { this._onLeftButtonDown(event); } else if (event.button === 1) { this._onMiddleButtonDown(event); } else if (event.button === 2) { this._onRightButtonDown(event); }};TouchInput._onRightButtonDown = function(event) { var x = Graphics.pageToCanvasX(event.pageX); var y = Graphics.pageToCanvasY(event.pageY); if (Graphics.isInsideCanvas(x, y)) { }};How do I use this?

I tried 'reverse engineering' http://forums.rpgmakerweb.com/index.php?/topic/48878-how-to-figure-out-if-right-mouse-button-is-pressed/ but I think I grew a tumor.

What is the 'event.button' and the '(event)' parameter?
 

S_Rank_Crazy

Veteran
Veteran
Joined
Dec 30, 2015
Messages
78
Reaction score
47
First Language
English
Primarily Uses
RMMV
At work at 5he moment but I'd imagine "event" is either a Game_Event object (the map objects) or a some native interpreter event used to pass data about an input action.

In 5his vase the "button" property looks like a code where 0: left mouse button, 1: middle, 2: right.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
Event is the data from the mouse down JS event, there's no relation to RM events.
 

Gyldstrand

Veteran
Veteran
Joined
Oct 16, 2014
Messages
76
Reaction score
4
So if I wanted to use a conditional to check if the right mouse button is pressed, what do I put for the '(event)'.

I tried the codes and a bunch of other unintelligible combinations. I get "button is not defined" most of the time.

Do I need to use a switch like in Hudell's OrangeMouseData.js to turn on when MouseDown and turn off when MouseUp?

A little elbow grease and we got it.  Here is what I did if anyone else has trouble with the easy parts:

TouchInput.clear = function() { this._mousePressed = false; this._screenPressed = false; this._pressedTime = 0; this._events = {}; this._events.triggered = false; this._events.cancelled = false; this._events.moved = false; this._events.released = false; this._events.wheelX = 0; this._events.wheelY = 0; this._triggered = false; this._cancelled = false; this._moved = false; this._released = false; this._wheelX = 0; this._wheelY = 0; this._x = 0; this._y = 0; this._date = 0; this._rightMouse = false;};TouchInput._onRightButtonDown = function(event) { var x = Graphics.pageToCanvasX(event.pageX); var y = Graphics.pageToCanvasY(event.pageY); if (Graphics.isInsideCanvas(x, y)) { this._rightMouse = true; }};TouchInput._onMouseUp = function(event) { if (event.button === 0) { var x = Graphics.pageToCanvasX(event.pageX); var y = Graphics.pageToCanvasY(event.pageY); this._mousePressed = false; this._onRelease(x, y); } else if (event.button === 2) { this._rightMouse = false; };};Then you can put 'TouchInput._rightMouse === true' in an event conditional.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top