Game Development Community

Mouse control no longer working

by Daniel Buckmaster · in Torque Game Engine · 11/26/2006 (8:09 am) · 10 replies

I just ran through the getting started tutorial, and successfully implemented everything that was there. However, when I run the game now, I can't control the character with the mouse. Keyboard controls are fine, but the mouse doesn't do anything except move the cursor around on the screen.
Is this a problem with a GUI, script file, or my mouse?

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
11/26/2006 (10:00 am)
Sounds like a GUI takes focus from your TSControl.
#2
11/26/2006 (10:06 am)
How can I fix that problem, then?
#3
06/16/2009 (5:34 am)
I'm having the same issue. Can somebody please post a solution? Is there a way to fix it? I can't control the character with the mouse. Keyboard controls are fine, but the mouse doesn't do anything except move the cursor around on the screen.
#4
06/16/2009 (5:49 am)
Canvas.showCursor();
Canvas.CursorOn();

Canvas.hideCursor();
Canvas.CursorOff();
#5
06/16/2009 (1:48 pm)
Forgive me for asking. But, where is Canvas.showCursor() and Canvas.CursorOn() located. Where would I go to make the change to Canvas.hideCursor();
Canvas.CursorOff();

I tried looking through the files that came with the SDK and I don't see it. I'm very new to Torque. Any help would be greatly appreciated. Thanks.
#6
06/16/2009 (11:53 pm)
The Canvas itself is initalized in (for example):
starter.fps/client/init.cs

Near line 46 you will find something like this...

// InitCanvas starts up the graphics system.
   // The canvas needs to be constructed before the gui scripts are
   // run because many of the controls assume the canvas exists at
   // load time.
   initCanvas("Torque Game Engine", true);
   if (!isObject(Canvas))
      // failed, don't make it worse by crashing...
      return;

Open the console and type "canvas.dump"
Now you will see all the members and methods available in the Canvas-Object.
#7
06/17/2009 (12:01 am)
Sorry, i forgot.
If you want to modify the Engine-Code itself, all methods are located in gui/core/guiCanvas.cc ( near line 144 ).

ConsoleMethod( GuiCanvas, showCursor, void, 2, 2, "")
{
   Canvas->showCursor(true);
}

ConsoleMethod( GuiCanvas, hideCursor, void, 2, 2, "")
{
   Canvas->showCursor(false);
}

#8
08/07/2009 (11:12 pm)
Could you tell me where they're located so I can make the changes?

Canvas.showCursor();
Canvas.CursorOn();

Canvas.hideCursor();
Canvas.CursorOff();

Where would I go to make the change to Canvas.hideCursor();
Canvas.CursorOff();

I'm looking at guiCanvas.cc. Do I change showCursor to false? I tried that and the mouse still didn't work. I remember someone posting where the Canvas.showCursor();
Canvas.CursorOn(); was located. I guess they must have deleted the post or something.
#9
08/08/2009 (2:12 am)
Sometimes a simpler solution is the answer. Did you by any chance modify your playGui.gui through the GUI Editor and then this behavior started happening?

If the answer is yes then check your parent GameTSCtrl in the PlayGui and make sure it has this line:
noCursor = "1";
#10
08/08/2009 (3:59 pm)
Thank you. It works!