Learning Scripting : Odd mouse question
by Manni Medeiros · in Torque 3D Professional · 11/16/2011 (8:51 pm) · 4 replies
So the code below works great it allows me to free the mouse and holding right click makes the mouse disappear and allow for movement
Real simple that works great! Now from what i understand of this code it watches the right mouse button and when its pressed in then it hides the cursor and I assume binds the mouse so controls work, then when released it unbinds the mouse and makes it visible again.
So now why does this code not work??
One would assume it does the same thing but with left click.This code does not appear to work, in fact it does nothing at all. So my question is how does this work so i can make the control work for the left click.
Assumption ahead:
I am thinking that when i call the function PlayGui::onRightMouseDown(%this, %pos, %start, %ray) it already exists somewhere and no one told me where so i have not been able to add the left click one. This is just my assumption.
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
GlobalActionMap.bind(mouse, "button1", toggleMouse);
}
function PlayGui::onRightMouseUp(%this, %pos, %start, %ray)
{
GlobalActionMap.unbind(mouse, "button1", toggleMouse);
}
function toggleMouse()
{
if(Canvas.isCursorOn()) {
hideCursor();
}
else
{
showCursor();
}
}Real simple that works great! Now from what i understand of this code it watches the right mouse button and when its pressed in then it hides the cursor and I assume binds the mouse so controls work, then when released it unbinds the mouse and makes it visible again.
So now why does this code not work??
function PlayGui::onLeftMouseDown(%this, %pos, %start, %ray)
{
GlobalActionMap.bind(mouse, "button0", toggleMouse);
}
function PlayGui::onLeftMouseUp(%this, %pos, %start, %ray)
{
GlobalActionMap.unbind(mouse, "button0", toggleMouse);
}
function toggleMouse()
{
if(Canvas.isCursorOn()) {
hideCursor();
}
else
{
showCursor();
}
}One would assume it does the same thing but with left click.This code does not appear to work, in fact it does nothing at all. So my question is how does this work so i can make the control work for the left click.
Assumption ahead:
I am thinking that when i call the function PlayGui::onRightMouseDown(%this, %pos, %start, %ray) it already exists somewhere and no one told me where so i have not been able to add the left click one. This is just my assumption.
About the author
Awkward Monkey was created by me and consists of me my wife and a few friends we are looking into expanding and love developing. Http://www.awkwardmonkey.com
#2
Also as a side note:
That makes no sense! If your going to use a naming convention Keep it the same GRRRRRR!
11/16/2011 (9:01 pm)
Ok that works thank you Kerry.Also as a side note:
That makes no sense! If your going to use a naming convention Keep it the same GRRRRRR!
#3
11/17/2011 (5:18 am)
Quote:That makes no sense! If your going to use a naming convention Keep it the same GRRRRRR!+1
#4
11/17/2011 (5:30 am)
It's Apple's fault for only having one mouse button. Only on the PC is the user considered dexterous enough to handle more than one button on a moveable object as complex as a mouse.
Kerry Enfinger
Altered Reality Software