Game Development Community

Changing the cursor in script

by Nathan Bowhay - ESAL · in Torque 3D Professional · 02/14/2011 (11:40 am) · 9 replies

I am guessing you can use Canvas.setCursor in script to change the cursor, but it doesn't seem to be working. Is there any trick to it? Something else I should use?

Here is an example of what I called in the console:
echo(isObject(LeftRightCursor));Canvas.setCursor("LeftRightCursor");

The isObject check returned true so I know it exists.

Thanks for any help in advance.

Side note: I noticed there is a showCursor, hideCursor, cursorOff, cursorOn. None of which do anything and not sure why there is hide/show and on/off.

PS: I guess it is because
mPlatformWindow->getCursorController()->isCursorVisible()
. So if you are using the windows cursors then it ignores it all. Now the only issue is I don't see any way of changing the windows cursor in script.

#1
02/15/2011 (8:14 am)
Check out the GuiCursor class in http://docs.garagegames.com/torque-3d/official/content/documentation/Scripting/Torque 3D - Script Manual.chm

I knew what you are looking to do is possible, but I haven't started on that part of my project yet. So, I did a quick lookup - which means I can only point you in the right direction. Sorry I can't be of more help right now.
#2
02/15/2011 (9:14 am)
Hmm for some reason I downloaded that file and when I click on the CuiCursor page it didn't show anything in the content area.

I will take a look in the stuff that comes with a build when I get to work.

Keep in mind though the code I have above uses GuiCursor. You call Canvas.setCursor and pass it a GuiCursor object. Hopefully though the documentation will talk more about using it.

Thanks for the tip, hopefully it will work, but we will see.
#3
02/15/2011 (10:01 am)
Make sure you unblock that .chm file if you haven't already.
#4
02/15/2011 (10:04 am)
I just open it and it (Windows 7) says do you want to open this file?... I click open. Then in the content area it always says Navigation to the webpage was canceled. What to try: Retype the address.
#5
02/15/2011 (10:05 am)
Oh never mind, guess checking the yes this is ok isn't enough you have to go into the file properties. Works now thanks Alex. Silly unintuitive windows 7 security.
#6
02/15/2011 (10:47 am)
Yeah that is all the stuff I have been trying and explained in my post. None of it seems to work.
#7
02/15/2011 (10:58 am)
This does not bode well for my upcoming GUI endeavors.... I guess we'd better Use the Source! There's got to be a solution somewhere - this has been done before.... lol
#8
02/15/2011 (11:06 am)
Yeah at some point (one of the T3D updates or T3D itself) they added a bunch of code to use the native cursors (windows in my case) there are checks in the code to see if the cursor manager is visible and if so ignore the other stuff. However in one of the cursorShow type functions it looks like it is setting the default cursors to not be visible and the script ones to be visible.
#9
03/15/2011 (1:20 pm)
Greetings!

Logged as THREED-1448 for someone to look into. Thanks!

- Dave