Hide/Show mouse cursor by pressing RMB (SOLVED)

There are no stupid questions, just stupid answers.
  • 1
  • 2
13 posts Page 2 of 2
Happenstance
Posts: 84
Joined: Sat Apr 11, 2015 9:08 pm
by Happenstance » Wed May 01, 2019 3:05 am
It might be worth tracing the code from here to see what's happening with the mouse events:
https://github.com/GarageGames/Torque3D ... s.cpp#L653

A workaround in script might be to also bind the right mouse button to a toggleCursor() function so that you're responding to the mouse event from both the GUI side (PlayGui::onRightMouseDown()) and the ActionMap side. You can find an example of how to do this in default.bind.cs but it'll look something like:
// button1 = Right Mouse Button
// binding to moveMap so that this only works in a level
moveMap.bind(mouse, button1, toggleCursor);

function toggleCursor(%val)
{
    if(%val)
    {
        showCursor();
    }
}
Jason Campbell
Posts: 314
Joined: Fri Feb 13, 2015 2:51 am
 
by Jason Campbell » Wed May 01, 2019 4:29 am

A workaround in script might be to also bind the right mouse button to a toggleCursor() function so that you're responding to the mouse event from both the GUI side (PlayGui::onRightMouseDown()) and the ActionMap side. You can find an example of how to do this in default.bind.cs but it'll look something like:
Exactly and thanks to Joel Schilling, I think his name was, who came up with a fix to the ActionMap. It's GlobalActionMap.

edit: Here's the post from GG: https://www.garagegames.com/community/f ... ead/104679

So leave noCursor=1; in playGui.gui

in scripts/client/default.bind.cs

Find moveMap.bind( mouse, button1, mouseButtonZoom ); and comment it out.

add to bottom:
moveMap.bind( mouse, button1, toggleCursor );


function toggleCursor()
{
   if(Canvas.isCursorOn()) {
      hideCursor();
   }
   else
   {
      showCursor();
   }
}
In scripts/gui/playGui.cs add to bottom:
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
   GlobalActionMap.bind(mouse, "button1", toggleMouse);
}

function PlayGui::onRightMouseUp(%this, %pos, %start, %ray)
{
   GlobalActionMap.unbind(mouse, "button1", toggleMouse);
}
Bishop
Posts: 66
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Wed May 01, 2019 6:14 pm
Thanks very much for help guys,
....Yes, exactly this works great....the cursor is hidden at the start of the game now and appears only after pressing and holding RMB.
Thanks Jason and Happenstance.
  • 1
  • 2
13 posts Page 2 of 2

Who is online

Users browsing this forum: No registered users and 3 guests