Losing mouse control of object at packaged game start
by Tetraweb · in Torque Game Builder · 02/25/2007 (4:17 am) · 10 replies
I am hiding the mouse cursor and binding the mouse movement to my player object at the beginning of the game like this:
It works great playing from the level editor; however when the game is packed into an app, it starts without the mouse hidden and no binding to the player object. I found that if I hit the tilde to show the console log and then hid it, the cursor would disappear.
As a workaround, after startup I push and the immediately pop a blankGui window, and that has the same effect as showing the console log, so I do startup with the mouse bound and hidden, but I wonder if anyone can point me towards the cause and a better solution.
Greg
new ActionMap( playerMap ); $pref::Input::MouseEnabled = 1; enableMouse(); playerMap.bind( mouse0 , "xaxis" , moveXAxis ); mainScreenGui.noCursor=true;
It works great playing from the level editor; however when the game is packed into an app, it starts without the mouse hidden and no binding to the player object. I found that if I hit the tilde to show the console log and then hid it, the cursor would disappear.
As a workaround, after startup I push and the immediately pop a blankGui window, and that has the same effect as showing the console log, so I do startup with the mouse bound and hidden, but I wonder if anyone can point me towards the cause and a better solution.
Greg
#2
has no effect, in fact errors that "0 is not a cursor"
Likewise Canvas.repaint() and Canvas.hideCursor() and Canvas.cursorOff() have no effect. Only the act of pushing a gui window with Canvas.pushDialog has the effect. (I found that I don't need to pop it, merely push it and I get the mouse binding.)
Greg
02/26/2007 (3:36 pm)
Canvas.setCursor(false)has no effect, in fact errors that "0 is not a cursor"
Likewise Canvas.repaint() and Canvas.hideCursor() and Canvas.cursorOff() have no effect. Only the act of pushing a gui window with Canvas.pushDialog has the effect. (I found that I don't need to pop it, merely push it and I get the mouse binding.)
Greg
#3
Please refer to the TDN page on GuiCanvas, which I have newly revised.
setCursor( GuiCursor cursor ) is for changing the appearance of the cursor. Sorry I sent you off in that direction. My documentation was incorrect, and I had to read the source to understand this one.
hideCursor() and showCursor() are the methods I should have suggested to you. You can ditch that statement mainScreenGui.noCursor = true, and just call hideCursor(), I think.
Someone turned me on to a TDN page that has something that might interest you: TorqueLocalization, Refreshing the Gui.
02/26/2007 (3:47 pm)
You have been busy! Me, too.Please refer to the TDN page on GuiCanvas, which I have newly revised.
setCursor( GuiCursor cursor ) is for changing the appearance of the cursor. Sorry I sent you off in that direction. My documentation was incorrect, and I had to read the source to understand this one.
hideCursor() and showCursor() are the methods I should have suggested to you. You can ditch that statement mainScreenGui.noCursor = true, and just call hideCursor(), I think.
Someone turned me on to a TDN page that has something that might interest you: TorqueLocalization, Refreshing the Gui.
#4
playerMap.bind( mouse0 , "xaxis" , moveXAxis );
I do seem to need the mainScreenGui.noCursor = true;
statement. Just using hideCursor() does not do it. Remember, I'm not just receiving mouse move events from the window, I'm creating the bind in a playerMap.
The statement
if(isObject(Canvas))
Canvas.setContent(Canvas.getContent());
does indeed work, and using this I don't have to pop and push a dialog. I have a feeling that both methods are doing the same refresh of the gui, in the end.
Thanks for your help on this.
Greg
02/27/2007 (5:41 pm)
With binding the xaxis of the mouse with:playerMap.bind( mouse0 , "xaxis" , moveXAxis );
I do seem to need the mainScreenGui.noCursor = true;
statement. Just using hideCursor() does not do it. Remember, I'm not just receiving mouse move events from the window, I'm creating the bind in a playerMap.
The statement
if(isObject(Canvas))
Canvas.setContent(Canvas.getContent());
does indeed work, and using this I don't have to pop and push a dialog. I have a feeling that both methods are doing the same refresh of the gui, in the end.
Thanks for your help on this.
Greg
#5
As you said, hideCursor() does absolutely nothing no matter where I put the call. Any solutions?
03/11/2007 (2:14 pm)
I have the same problem. The only way my bound mouse click will work is if mainScreenGui.noCursor = true; is used. This is a total pain in the ass of course because my mouse completely disappears from the whole OS (Mac OS X).As you said, hideCursor() does absolutely nothing no matter where I put the call. Any solutions?
#6
Are you using mainScreenGui.noCursor = true; or hideCursor() with
if(isObject(Canvas))
Canvas.setContent(Canvas.getContent());
?? And also, where are you calling that from? Trying to figure out how i can use my mouse and still have it not completely disappear from all apps. Very aggravating! Thanks for the help :)
03/12/2007 (9:30 am)
@TetrawebAre you using mainScreenGui.noCursor = true; or hideCursor() with
if(isObject(Canvas))
Canvas.setContent(Canvas.getContent());
?? And also, where are you calling that from? Trying to figure out how i can use my mouse and still have it not completely disappear from all apps. Very aggravating! Thanks for the help :)
#7
playerMap.bind( mouse0 , "xaxis" , moveXAxis );
then you do need to have
MainScreenGui.noCursor = true;
In practice, this is only really suitable for fullscreen games; because you are essentially taking over the mouse completely from the OS.
It may be a better solution for you to use the scene onMouseMove functions. Using these, you can hide the mouse only when it is inside your windowed game, and make it available when the user moves outside your window. For what I'm working on, I needed constant direct access to the mouse's x-axis motion, and it is destined to be full screen only.
Useful threads:
www.garagegames.com/mg/forums/result.thread.php?qt=26532
www.garagegames.com/mg/forums/result.thread.php?qt=49130
Greg
03/12/2007 (1:13 pm)
If you are binding the mouse to a function withplayerMap.bind( mouse0 , "xaxis" , moveXAxis );
then you do need to have
MainScreenGui.noCursor = true;
In practice, this is only really suitable for fullscreen games; because you are essentially taking over the mouse completely from the OS.
It may be a better solution for you to use the scene onMouseMove functions. Using these, you can hide the mouse only when it is inside your windowed game, and make it available when the user moves outside your window. For what I'm working on, I needed constant direct access to the mouse's x-axis motion, and it is destined to be full screen only.
Useful threads:
www.garagegames.com/mg/forums/result.thread.php?qt=26532
www.garagegames.com/mg/forums/result.thread.php?qt=49130
Greg
#8
Do I still need to use hideCursor() with that?
Thanks for the help Greg!! :)
-James
03/12/2007 (1:51 pm)
Oh ok, I'll try out the onMouseMove functions tonight!Do I still need to use hideCursor() with that?
Thanks for the help Greg!! :)
-James
#9
Thank you!!!
03/12/2007 (4:52 pm)
OMGWTFBBQ!! you rock! That did exactly what I needed, and was simple as hell.Thank you!!!
#10
(@James) Also as Tetraweb pointed out, the scene window mouse callbacks are definitely the preferred ones (they are in the reference). Though in certain cases (like Tetraweb's situation) you would use the ActionMap bindings.
03/13/2007 (2:31 pm)
Great job helping each other... unfortunately I think you've found that reseting the canvas or pushing and popping a GUI is probably the only way to get it to work. Fortunately though that shouldn't cause much of a problem (if any), though is something we need to look into.(@James) Also as Tetraweb pointed out, the scene window mouse callbacks are definitely the preferred ones (they are in the reference). Though in certain cases (like Tetraweb's situation) you would use the ActionMap bindings.
Torque Owner Arthur Ogawa
I, too, have observed that opening and closing the console log window would have an affect on my Gui's state. Perhaps the gui is being re-rendered.
One suggestion: take a look at GuiCanvas::setCursor( bool visible ). (You can find documentation in your local documentation under Reference->TGB Reference->GuiCanvas->Methods->setCursor or in TDN under GuiCanvas.) You may find this call has a more immediate effect.