Locking Mouse
by Playware · in Torque Game Builder · 11/28/2007 (8:21 pm) · 9 replies
Hi,
I need some help regarding locking the mouse.
Actually in window mode game, once we reach on the border , the mouse goes out from window and you can do anything on your desktop. Here I want to lock the mouse to go out from my window area.
How could be possible this? First I tried something. For this I got the mouse position by sceneWindow2D.getMousePosition(); then according to my resolution (800x600) , I cheked if mouse position going out from horizontal position>=400 or <= -400 and vertical position >= 300 or <= -300, I called
Canvas.hidecursor() with $cursorControlled = true; Here it is hiding the cursor once it reached window border, but again it is going out from window as usual.
any solution for this will be very helpfull.
Thanks in advance..
regards.
I need some help regarding locking the mouse.
Actually in window mode game, once we reach on the border , the mouse goes out from window and you can do anything on your desktop. Here I want to lock the mouse to go out from my window area.
How could be possible this? First I tried something. For this I got the mouse position by sceneWindow2D.getMousePosition(); then according to my resolution (800x600) , I cheked if mouse position going out from horizontal position>=400 or <= -400 and vertical position >= 300 or <= -300, I called
Canvas.hidecursor() with $cursorControlled = true; Here it is hiding the cursor once it reached window border, but again it is going out from window as usual.
any solution for this will be very helpfull.
Thanks in advance..
regards.
About the author
#2
11/30/2007 (10:25 pm)
It highly depends on the game. I'm looking for a way to lock the mouse too.
#3
12/01/2007 (1:41 pm)
I don't see anything wrong with locking the mouse during gameplay, and releasing it when paused. Probably a pretty good idea in some situations.
#4
Locking the mouse is taking control of their screen, which is fine if necessary. But go all the way and commit to using fullscreen if you are going to to it. Don't do it in windowed mode and show them their Outlook Express window peeking out behind it but not let them get to it.
Greg
12/01/2007 (5:28 pm)
As I have ranted elsewhere locking the mouse in windowed mode is almost always a bad idea.Locking the mouse is taking control of their screen, which is fine if necessary. But go all the way and commit to using fullscreen if you are going to to it. Don't do it in windowed mode and show them their Outlook Express window peeking out behind it but not let them get to it.
Greg
#5
I know there's a way to clamp, because in the builder when you maintain the right mouse button to move the camera, the mouse is locked cleanly. But I can't figure out how.
12/01/2007 (9:57 pm)
Quote:fullscreenIt is not enough. In dual screen nothing prevent the mouse from moving outside of the first screen to the other screen, it's painful when it happens.
I know there's a way to clamp, because in the builder when you maintain the right mouse button to move the camera, the mouse is locked cleanly. But I can't figure out how.
#6
While understanding certain issues can be solved through design, they are certain features I required firmly due to various reasons.
Maybe there is a misunderstanding here. Let me rephrase my question.
My programming skill for window is very basic, limited and lazy if you want to call it. I would like to learn in Torque Game Builder Engine if it is possible to restrain mouse cursor out off the window in window mode from the PROGRAMMING POINT OF VIEW. Do I need to apply Window Prgramming Knowledge myself or if there is any area I can apply the changes directly in the C source.
For example say maybe the canvas class would be the best place to start with, etc..
Any Ideas ...........?
thnx.
12/03/2007 (1:43 am)
I really appreaciate for the suggestions and help.While understanding certain issues can be solved through design, they are certain features I required firmly due to various reasons.
Maybe there is a misunderstanding here. Let me rephrase my question.
My programming skill for window is very basic, limited and lazy if you want to call it. I would like to learn in Torque Game Builder Engine if it is possible to restrain mouse cursor out off the window in window mode from the PROGRAMMING POINT OF VIEW. Do I need to apply Window Prgramming Knowledge myself or if there is any area I can apply the changes directly in the C source.
For example say maybe the canvas class would be the best place to start with, etc..
Any Ideas ...........?
thnx.
#7
Actually, the mouse does not lock itself to the builder's window. The function that is called when the mouse is dragged is called "onRightMouseDragged", and is only called when the mouse is within the bounds of the scene. It appears to lock because the function isn't called from the point it leaves the scene, until it goes back in.
12/03/2007 (2:39 am)
Quote:I know there's a way to clamp, because in the builder when you maintain the right mouse button to move the camera, the mouse is locked cleanly. But I can't figure out how.
Actually, the mouse does not lock itself to the builder's window. The function that is called when the mouse is dragged is called "onRightMouseDragged", and is only called when the mouse is within the bounds of the scene. It appears to lock because the function isn't called from the point it leaves the scene, until it goes back in.
#9
12/04/2007 (3:39 pm)
I don't think there's any way to do this without modifying the source.
Torque Owner Joe Rossi
Indri Games