InitMouse(#PB_Mouse_Locked)

Just starting out? Need help? Post your questions and find answers here.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

InitMouse(#PB_Mouse_Locked)

Post by MrTAToad »

When passed as a parameter, #PB_Mouse_Locked doesn't actually seem to do anything - still get the system pointer displayed.
Fred
Site Admin
Posts: 1821
Joined: Mon Feb 24, 2014 10:51 am

Re: InitMouse(#PB_Mouse_Locked)

Post by Fred »

Juts tried with Chrome and FireFox, and it seems to work as expected. Note: you need to click once on the screen to enable mouse locking.

Code: Select all

InitMouse(#PB_Mouse_Locked)

OpenScreen(800, 600, 32, "Test")

Procedure RenderFrame()
  Static x, y
  
  ClearScreen(RGB(0, 0, 0))
  
  If ExamineMouse()
    
    If MouseButton(#PB_MouseButton_Left)
      Debug "Left button"
    EndIf
    
    If MouseButton(#PB_MouseButton_Right)
      Debug "Right button"
    EndIf
    
    If MouseButton(#PB_MouseButton_Middle)
      Debug "Middle button"
    EndIf
    
    WheelDelta = MouseWheel()
    If WheelDelta
      Debug "Mouse wheel: " + WheelDelta
    EndIf
  EndIf
  
  FlipBuffers(); // continue the rendering
EndProcedure

BindEvent(#PB_Event_RenderFrame, @RenderFrame())
FlipBuffers(); 
ps: please always post a small full working snippet showing the bug so it's easier to test.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: InitMouse(#PB_Mouse_Locked)

Post by MrTAToad »

Yes, I think the lack of initial clicking was the cause of the problem...
Post Reply