Restrict mouse movement
Restrict mouse movement
Is there a simple and fast command or method for restricting mouse movement to a specific area of the display while a certain condition is true?
Re: Restrict mouse movement
Perhaps this does not qualify for the "simple and fast" criterias, but it will limit the mouse movements
Code: Select all
@DISPLAY {Width = 640, Height = 480}
Function p_keyhandler(msg)
Switch(msg.action)
Case "CloseWindow":
End
Case "OnRawKeyDown":
If msg.key = "X" Then p_poscheck
EndSwitch
EndFunction
Function p_poscheck()
xpos = MouseX()
ypos = MouseY()
If xpos > 590
xpos = 590
outsidelimit = True
EndIf
If xpos < 50
xpos = 50
outsidelimit = True
EndIf
If ypos > 430
ypos = 430
outsidelimit = True
EndIf
If ypos < 50
ypos = 50
outsidelimit = True
EndIf
If outsidelimit
MovePointer(xpos, ypos)
outsidelimit = False
EndIf
EndFunction
InstallEventHandler({OnRawKeyDown = p_keyhandler, CloseWindow = p_keyhandler})
Repeat
WaitEvent()
Forever