Finding out if left mouse is down
by Ian Omroth Hardingham · in Torque 3D Professional · 09/23/2013 (5:01 am) · 9 replies
Hey guys.
Is there a function to check the up/down status of a key or mouse button?
(And no, I do not want to set a variable to true in the on down method)
Cheers,
Ian
Is there a function to check the up/down status of a key or mouse button?
(And no, I do not want to set a variable to true in the on down method)
Cheers,
Ian
About the author
Designer and lead programmer on Frozen Synapse, Frozen Endzone, and Determinance. Co-owner of Mode 7 Games.
#2
09/23/2013 (6:21 am)
Cheers Richard. Yeah I'm looking for something lower-level than that.
#3
09/23/2013 (7:58 am)
Think you're going to have to write that yourself - the whole thing is event-driven so there is no polling.
#4
Pretty sure that's not low-level enough for what you want tho.
09/24/2013 (12:32 am)
You could always try using bindCmd() as you usually would for mouse functions, then setting a global, call it $leftMouseDown, to true in the 'make' and false in the 'break'. Then you can check at any time whether that variable is true or false and you should known whether the mouse button is down.Pretty sure that's not low-level enough for what you want tho.
#5
Frank - that solution just doesn't work. If you mouse down over the playGui and mouse up over a different gui element the bound command will not call a second time.
Ian
09/24/2013 (1:32 am)
Hey guys, thanks.Frank - that solution just doesn't work. If you mouse down over the playGui and mouse up over a different gui element the bound command will not call a second time.
Ian
#6
So as Richard said: you're going to have to write it yourself.
09/24/2013 (1:45 am)
Ah - you probably need to look into the engine itself and exposing some of the hardware handling to script then.So as Richard said: you're going to have to write it yourself.
#7
09/24/2013 (6:28 am)
Wait - is this specifically for use in GUIs? If so, you could create invisible drag-drop controls on the fly then just handle the onDropped() in all of your GUIs. Maybe the onDragged (onDragging?) too.
#8
09/24/2013 (6:36 am)
Ian: You'll want to change the callback event myControl::OnMouseDown(%this) in TorqueScript to do %this.makeFirstResponder(true); that way you'll guarantee a myControl::OnMouseUp(%this) event. Might even want to do %this.makeFirstResponder(false); in OnMouseUp callback.
#9
09/24/2013 (6:38 am)
I'm afraid that really doesn't guarantee anything. *Anything* can happen between a mouse down and a mouse up event.
Torque Owner Richard Ranft
Roostertail Games