Adam's Lair Forum
https://forum.adamslair.net:80/

Hide mouse cursor at runtime
https://forum.adamslair.net:80/viewtopic.php?f=4&t=1251
Page 1 of 1

Author:  tufduck [ 2018/09/11, 16:17 ]
Post subject:  Hide mouse cursor at runtime

Short question, how do I hide the mouse cursor in-game?

I tried
Code:
 DualityApp.UserData.SystemCursorVisible = false;
but that didn't have any effect.

I want the system mouse cursor on by default, but in certain situations in-game I wish to hide it. Is that possible?

Author:  SirePi [ 2018/09/11, 18:18 ]
Post subject:  Re: Hide mouse cursor at runtime

Going by memory here, but if I don't remember wrong you need to reassign the whole UserData object

Code:
var userData = DualityApp.UserData;
userData.SystemCursorVisible = false;
DualityApp.UserData = userData;

Author:  tufduck [ 2018/09/11, 19:05 ]
Post subject:  Re: Hide mouse cursor at runtime

Hmm.. that did hide the mouse cursor, but it totally messed up the resolution. The whole screen went black for a second and then Windows popped up a warning with "This is not your primary resolution etc. etc..."

I tried this
Code:
var userData = DualityApp.UserData;
            userData.GfxHeight = (int)DualityApp.TargetResolution.Y;
            userData.GfxWidth = (int)DualityApp.TargetResolution.X;
            userData.SystemCursorVisible = false;
            DualityApp.UserData = userData;


But no difference.

Any more ideas? :)

Author:  SirePi [ 2018/09/11, 21:25 ]
Post subject:  Re: Hide mouse cursor at runtime

Weird.. for me it works (tested both on duality v2 and v3) :wtf:

Gfycat Video - Click to Play. [Source]


Code:
void ICmpUpdatable.OnUpdate()
{
   if (DualityApp.Keyboard.KeyHit(Duality.Input.Key.Space))
   {
      var userData = DualityApp.UserData;

      userData.SystemCursorVisible = !userData.SystemCursorVisible;
      DualityApp.UserData = userData;
   }
}

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/