SetCursor not working in 3.0
by Howard Dortch · in Torque 3D Professional · 05/30/2013 (9:53 am) · 13 replies
new GuiCursor( HandCursor )
{
hotSpot = "1 1";
renderOffset = "0 0";
bitmapName = "core/art/gui/images/CUR_hand";
};
in Playgui.cs onMouseMove
Canvas.setCursor(HandCursor);
nothing happens.
I put an echo in the onMouseMove before and after the setCursor so I know it gets hit.
Any help?
#2
05/30/2013 (6:31 pm)
thanks for the reply. Anyone else? I would be happy with a software cursor at this point.
#3
Either way changes to the engine are required. I don't have the code for the software version anymore sorry - I think it was based on an old resource to added support for animated cursors tho.
05/30/2013 (9:37 pm)
I got the software version working in the engine before going down the platform route - however it didn't work within the world editor and lagged quite a bit.Either way changes to the engine are required. I don't have the code for the software version anymore sorry - I think it was based on an old resource to added support for animated cursors tho.
#4
Not sure if you've looked into it - or it's what you need, but AFX also has a solution for setting a hand cursor on rollover of objects based on a mask. It uses platform cursor as well, but the selection mask is scriptable.
05/30/2013 (9:44 pm)
@Howard. Saw your other post too around setting a hand cursor.Not sure if you've looked into it - or it's what you need, but AFX also has a solution for setting a hand cursor on rollover of objects based on a mask. It uses platform cursor as well, but the selection mask is scriptable.
#5
I hoped GG would have fixed this by now
05/31/2013 (4:31 am)
Thanks for the reply. Do you have a link to the AFX solution?I hoped GG would have fixed this by now
#6
05/31/2013 (6:45 am)
Oddly enough, they have fixed it several times - and it somehow keeps falling apart again. I've had it work fine, then fail, then work as the versions roll by.
#7
I looked at the directX code and it looks simple enough to implement. I guess they are trying to keep the windows platform stuff intact but even that cursor changes when you get on a edge of a window.
05/31/2013 (8:34 am)
I guess features are more important than function.I looked at the directX code and it looks simple enough to implement. I guess they are trying to keep the windows platform stuff intact but even that cursor changes when you get on a edge of a window.
#8
The way it use to work was to tell the window manager to hide its mouse cursor so that whenever it was on top of the application window it would be invisible and Torque would draw a texture at the corresponding mouse position over the window when its suppose to be in a visible state on the engine side. The code to hide/show the window manager's mouse cursor is still intact, so just need to find the code that draws the mouse cursor using a set texture by Canvas.setCursor().
05/31/2013 (11:13 am)
Mouse cursors are not manually drawn by Torque via GPU like they were in the TGE and TGEA days, but instead the window manager is responsible for drawing the mouse cursors/pointers. This was done in T3D at the same time that menu bars and their menus were window manager handled too instead of being drawn by Torque its self.I don't know if TGE/TGEA style mouse cursor handling code is still in T3D or not.The way it use to work was to tell the window manager to hide its mouse cursor so that whenever it was on top of the application window it would be invisible and Torque would draw a texture at the corresponding mouse position over the window when its suppose to be in a visible state on the engine side. The code to hide/show the window manager's mouse cursor is still intact, so just need to find the code that draws the mouse cursor using a set texture by Canvas.setCursor().
#9
Good luck.
05/31/2013 (11:16 am)
Howard, if you use this resource then it should be working. I had no problems to get this in T3D 3.0.Good luck.
#10
The check for mPlatformWindow->getCursorController()->isCursorVisible() is what prevents software cursors from being drawn. If you bypass that and disable the platform cursor from showing it works. I'm not sure if there is a better method already implemented to make them work but this is what I found when I couldn't get them working myself.
05/31/2013 (11:16 pm)
The code for software cursors still works as it should it's just overridden by the platform code it seems. In guiCanvas.cpp:// Really draw the cursor. :)
// Only if the platform cursor controller is missing or the platform cursor
// isn't visible.
if (!mPlatformWindow->getCursorController() || (mCursorEnabled && mouseCursor && mShowCursor) &&
!mPlatformWindow->getCursorController()->isCursorVisible())
{
Point2I pos((S32)mCursorPt.x, (S32)mCursorPt.y);
Point2I spot = mouseCursor->getHotSpot();
pos -= spot;
mouseCursor->render(pos);
}The check for mPlatformWindow->getCursorController()->isCursorVisible() is what prevents software cursors from being drawn. If you bypass that and disable the platform cursor from showing it works. I'm not sure if there is a better method already implemented to make them work but this is what I found when I couldn't get them working myself.
#11
06/01/2013 (5:58 am)
Good info. Seems a check for software cursor could be a switch in there. Thanks...
#12
I want to be able to switch between the mouse grab and the run and gun reticle. I can open the console in game and do this:
playgui.nocursor = 1 and I get the free running target reticle.
playgui.nocursor = 0 and I get the software mouse grab ability
I tried to use a keybind to alter between the two but can't make that work.
function toggleMouse(%val)
{
if(%val)
{
if(playgui.nocursor == 0)
{
playgui.nocursor = 1;
}
else
{
playgui.nocursor = 0;
}
}
}
The call gets made on M key down but nothing happens. Anyone know a trick here?
06/03/2013 (8:59 am)
Ok I added a console command to kill the hardware cursor and all is well with the software pointer, hand and grab graphics. I want to be able to switch between the mouse grab and the run and gun reticle. I can open the console in game and do this:
playgui.nocursor = 1 and I get the free running target reticle.
playgui.nocursor = 0 and I get the software mouse grab ability
I tried to use a keybind to alter between the two but can't make that work.
function toggleMouse(%val)
{
if(%val)
{
if(playgui.nocursor == 0)
{
playgui.nocursor = 1;
}
else
{
playgui.nocursor = 0;
}
}
}
The call gets made on M key down but nothing happens. Anyone know a trick here?
#13
06/03/2013 (2:27 pm)
Hey, I think showCursor and hideCursor should do the trick - have to try it though, can't remember if that's T2D, T3D or both....
Torque Owner Adam Beer
Ignition Games Inc.
www.garagegames.com/community/forums/viewthread/128014