korlibs / korlibs/korge

lock and hide cursor

Open
#636 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
3k
Forks
148
Avg merge
13h 44m
Merged PRs (30d)
1

Description

I add `lock and hide cursor` in my fork for 3d game(like minecraft), but I meet something problem, look at code:
```
override fun setPointerLockable(isLockable:Boolean) {
val robot = Robot()
val mot = object:MouseMotionListener{
override fun mouseMoved(e: MouseEvent?) {
robot.mouseMove(nativeComponent.width/2+nativeComponent.locationOnScreen.x,nativeComponent.height/2+nativeComponent.locationOnScreen.y)
}
override fun mouseDragged(e: MouseEvent?) {
robot.mouseMove(nativeComponent.width/2+nativeComponent.locationOnScreen.x,nativeComponent.height/2+nativeComponent.locationOnScreen.y)
}
}
if(isLockable){
nativeComponent.addMouseMotionListener(mot)
return
}
nativeComponent.removeMouseMotionListener(mot)
}
```
But when I move mouse quickly, I may see the cursor,because the windows is small, cursor move out of windows.
- Are there someway to disable the cursor?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the setPointerLockable override and inspect how nativeComponent handles mouse motion and cursor visibility. Reproduce the fast-movement case in a small desktop 3D game, then verify that locking keeps the cursor hidden or contained and that disabling the lock restores normal cursor behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
desktop, game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.