HeroEngine Forums

HeroEngine Support => Scripting & Programming => Topic started by: Ratchet_Dev on Apr 30, 16, 02:35:57 PM

Title: Hiding Cursor in HSL
Post by: Ratchet_Dev on Apr 30, 16, 02:35:57 PM

Does anyone know what the default Hide Cursor command is in HSL?

I'm using this script that gets called when a comma or period is pressed, and it has debugging.

It does call (as shown below in the console) but does not actually hide the cursor.
Does anyone know the actual code to hide and lock the cursor to the center, as I have had no luck so far on the Wiki.
Title: Re: Hiding Cursor in HSL
Post by: Thazager on Apr 30, 16, 07:48:09 PM
A few ideas I had a by looking thru the code in _CursorClassMethods.

public function CursorDisplay()
    cursor as NodeRef of Class GUIControl = $Cursor._getCustomCursor()
    cursor.visible = true

public function CursorHide()
    cursor as NodeRef of Class GUIControl = $Cursor._getCustomCursor()
    cursor.visible = false

// or move cursor off screen to hide

  position as Vector3 = GetMousePosition()
  where cursor is kindof GUIControl
    cursor.position.x = -100 // off screen
    cursor.position.y = -100 // off screen
Title: Re: Hiding Cursor in HSL
Post by: FI-ScottZ on Apr 30, 16, 08:05:18 PM
I believe the $Cursor system node usage is if you are using software cursors (i.e. drawn by the gui system) but does not affect hardware cursors (the built-in Windows system).

Are you using a custom hardware cursor via SetCursor()?  Because for some unknown reason, SetCursorVisibility(false) only works for the default Windows cursor, which is set via SetCursor("").

We use multiple custom cursors.  Previously we tried setting to the default cursor when we wanted to hide it, but it was not always consistent.  What we ended up doing to ensure it always works is to upload a fully transparent PNG image (1 pixel square works fine) as a blank "cursor", then when we want to hide the cursor we use SetCursor() to set it to our blank one.  Thus we are not using SetCursorVisibility().

Important Note: If you do use SetCursor() like we did, and pair it with a call to SetIgnoreCursor(), you MUST call SetCursor() BEFORE SetIgnoreCursor(), or we found that sometimes the cursor would become lost and no longer reappear.  A lot of frustrating trial-and-error to figure out that bug. :'(