TGEA 1.8.1 Bug - get/set CursorPos
by Mark Dynna · in Torque Game Engine Advanced · 07/13/2009 (9:40 pm) · 4 replies
I'm still trying to track down the cause, but I just confirmed this so I wanted to post it here.
Either the Canvas::getCursorPos function is reporting incorrectly or the Canvas::setCursorPos function is setting incorrectly because the following code causes the cursor to "jump" positions on a screen. In a Windowed game doing this a couple of times will cause the cursor to "jump" out of the window.
Either the Canvas::getCursorPos function is reporting incorrectly or the Canvas::setCursorPos function is setting incorrectly because the following code causes the cursor to "jump" positions on a screen. In a Windowed game doing this a couple of times will cause the cursor to "jump" out of the window.
Canvas.setCursorPos(Canvas.getCursorPos());
#2
Hmm, rather than being the fault of the cursor controller (which correctly operates in screen coords on both win and mac), it looks like GuiCanvas is keeping cursor coordinates in local window space when it claims to keep them in screen space.
However, even when I adjusting for this, I see some jumping that I haven't yet found the cause for. Maybe it's confusing coordinate spaces somewhere in the event handling code.
07/14/2009 (9:13 am)
Hmm, rather than being the fault of the cursor controller (which correctly operates in screen coords on both win and mac), it looks like GuiCanvas is keeping cursor coordinates in local window space when it claims to keep them in screen space.
However, even when I adjusting for this, I see some jumping that I haven't yet found the cause for. Maybe it's confusing coordinate spaces somewhere in the event handling code.
#3
When in "Window Mode", I placed my cursor in the bottom-right corner of the screen, then in console:
Clearly something isn't right there... Everytime I run this:
My cursor jumps to the upper left quadrant.
If I do:
Then this works:
Am I forever forced to force my end-users to run in "Maximized" Window mode?
FYI: "Full Screen" mode works no matter what resolution I use.
07/07/2010 (4:55 pm)
Any luck on this?When in "Window Mode", I placed my cursor in the bottom-right corner of the screen, then in console:
==>echo(canvas.getvideomode()); 800 600 false 32 60 0 ==>echo(canvas.getcursorpos()); 1010 731
Clearly something isn't right there... Everytime I run this:
==>canvas.setcursorpos(canvase.getcenter());
My cursor jumps to the upper left quadrant.
If I do:
==>canvas.maximizeWindow();
Then this works:
==>canvas.setcursorpos(canvase.getcenter());
Am I forever forced to force my end-users to run in "Maximized" Window mode?
FYI: "Full Screen" mode works no matter what resolution I use.
#4
//Edit:
Argh... darn it... I will never get this right. Once again, my post was describing T3D behavior and not TGEA behavior. getCursorPos() is probably broken in TGEA.
--------
Actually, the behavior you see is intended. getCursorPos() returns the cursor position in screen-space coordinates. To convert, simply use GuiCanvas.screenToClient(), i.e.
07/07/2010 (4:58 pm)
//Edit:
Argh... darn it... I will never get this right. Once again, my post was describing T3D behavior and not TGEA behavior. getCursorPos() is probably broken in TGEA.
--------
Actually, the behavior you see is intended. getCursorPos() returns the cursor position in screen-space coordinates. To convert, simply use GuiCanvas.screenToClient(), i.e.
Canvas.screenToClient( Canvas.getCursorPos() );
Associate Rene Damm
Confirmed. Think it's because the platform cursor controllers don't translate from local window coordinates to global screen coordinates. Will fix this and post the changes.