HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Hiding Mouse Cursor  (Read 1438 times)

brainache

  • World Owner
  • ****
  • Posts: 121
    • View Profile
Hiding Mouse Cursor
« on: Jan 23, 13, 06:02:43 PM »

Hey folks...

Having some problems trying to hide/unhide the mouse curosr...
I've read the resolved thread on the issue ( https://community.heroengine.com/forums/index.php/topic,440.msg1698.html#msg1698 )

and I am using every method mentioned in the thread to hide the cursor, but nothing is affecting it:

The camera state and ignorecursor both are working - so I know the code is getting called...

    is "ToggleCursor"
      if (GetCmdState("Camera","DragRotate"))
        SetCmdState("Camera","DragRotate",false)
        SetCursorVisibility(true)
        $Cursor._setCustomCursorVisibility(true)
        SetCursor( "\GUI\cursor-arrow.tif")
        SetIgnoreCursor(false)
      else
        SetCmdState("Camera","DragRotate",true)
        SetCursorVisibility(false)
        $Cursor._setCustomCursorVisibility(false)
        SetCursor("")
        SetIgnoreCursor(true)
      .
    .


I'm calling this from Input_Command if that makes a difference...

Any ideas?
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Hiding Mouse Cursor
« Reply #1 on: Jan 23, 13, 06:21:55 PM »

Try putting SetCursor("") before SetCursorVisibility(false); as you have it currently, SetCursorVisibility is still being called on the custom cursor.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

brainache

  • World Owner
  • ****
  • Posts: 121
    • View Profile
Re: Hiding Mouse Cursor
« Reply #2 on: Jan 23, 13, 06:41:32 PM »

Hmm.. didnt change the behavior...
I do get an error message when it untoggles saying that the setcurosr cant find the texture ( which i know isnt there... not worried about that...) so..  i know its "trying" I suppose... but.. the cursor stays visible at all times...
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Hiding Mouse Cursor
« Reply #3 on: Jan 23, 13, 08:36:12 PM »

For the sake of context, would you paste the entire function this code is in?  I'm curious about that is "ToggleCursor" line.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

brainache

  • World Owner
  • ****
  • Posts: 121
    • View Profile
Re: Hiding Mouse Cursor
« Reply #4 on: Jan 23, 13, 08:53:56 PM »

Here is the function.. its the cmdStop function from Input_Command
note: I didnt copy the rest of the cmdStop from Input_Command as its pretty long...

I have "ToggleCursor" keybound to a key...  it works quite well for toggling in/out of a camera lock fps type mouselook..  the cursor glues to middle of the screen thanks to SetIgnoreCursor.. but I just cant get the cursor to hide...

function onCmdStop(cmd as String) as Boolean
  when cmd
    is "ToggleCursor"
      if (GetCmdState("Camera","DragRotate"))
        SetCmdState("Camera","DragRotate",false)
        SetIgnoreCursor(false)
        SetCursorVisibility(true)
        $Cursor._setCustomCursorVisibility(true)
        SetCursor( "\GUI\cursor-arrow.tif")
      else
        SetCmdState("Camera","DragRotate",true)
        SetIgnoreCursor(true)
        $Cursor._setCustomCursorVisibility(false)
        SetCursor("")
        SetCursorVisibility(false)
      .
    .
   
    is "PlayMode"
      $PLAYMODE._togglePlayModeState()
    .
    is "LeftButton"
      println("Command - LeftButton")
    .
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Hiding Mouse Cursor
« Reply #5 on: Jan 23, 13, 09:44:44 PM »

If I'm reading that correctly, then if the "ToggleCursor" is triggered by a key press, then you have a check for DragRotate inside of it, that would mean the toggle would only happen if you were right-dragging the mouse while you pressed the key.  That seems odd.  Is that what you intended?
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

brainache

  • World Owner
  • ****
  • Posts: 121
    • View Profile
Re: Hiding Mouse Cursor
« Reply #6 on: Jan 23, 13, 10:30:54 PM »

That is not what I think is going on...  I could be wrong... but here is my take based on what I see happening...

ToggleCursor happens whenever the Z key is released.. that stats the onCmdStop function with ToggleCursor as the cmd...

GetCmdState ("Camera","DragRotate") checks a true/false varaibe  (well.. i assume a t/f var.. might be interger based.. no idea there)...  on the Camera command layer...

in the onmousemove... it checks that variable to determine if the camera should rotate on mouse move

in the clean engine.. the rightmouse button sets the DragRotate cmd state...

so i just hooked into that method and set the state (the SetCmdState("Camera","DragRotate",true/false) statements)  via keypress instead of rightmouse...

as far as toggling the mouselook - that works absolutely perfectly.

i press z, my mouse locks into mouselook, i press z again, mouse unlocks...

« Last Edit: Jan 23, 13, 10:34:00 PM by brainache »
Logged