Repository navigation
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
I'm trying to implement a "zoom" feature in my app and i really find the one in Ableton Live to have the best feel/UX.
0913.mov
Notice that the mouse cursor disappears on what would be the Flutter Listener's onPointerDown equivalent, and then I can move the mouse as much as I have space on my desk upwards, while normally the cursor would quickly hit the top of my screen.
This is how it looks like in my app. The Listener's onPointerMove is limited by the screen's real estate.
0913.1.mov
Proposal
Any ideas on how I could "hide" the cursor in flutter and count the mouse travelled distance pixels in a virtually infinite space?
Reacted by Vlad Voina, Hosam Hasan Ramadan, René Kilczan and Jan Mewes
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
moffatman commentedon Sep 13, 2023
This would be implementing "mouse cursor capture" on supported desktop platforms. Through some new API I guess. Similar to how a FPS game might want to capture the mouse. No way at all to do it at the moment, let's keep this issue open to track such a feature.
alexvoina commentedon Sep 13, 2023
This is functionality is implemented in JUCE (a C++ framework for audio apps).
documentation:
https://docs.juce.com/master/classMouseInputSource.html#ad0065b78d89d7dafdcd183fcafccf852
code:
https://github.com/juce-framework/JUCE/blob/HEAD/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h#L444
I didn't carefully check the code but it looks doable
moffatman commentedon Sep 13, 2023
For reference to anyone interested in working on it
I guess Flutter API would look something like
GestureBinding.instance.capturePointer(int deviceId)GestureBinding.instance.releasePointer(int deviceId, {bool restoreOriginalPosition = true})dkwingsmt commentedon Sep 14, 2023
Sounds legit. I wonder how mouse events are reported natively when captured? IIRC currently Flutter computes position delta by subtracting positions, so I assume either the position will be unbounded or the position delta will be explicitly given?
16 remaining items
helgoboss commentedon Nov 10, 2023
Not sure, I didn't inspect your code. But one possibility is that it's related to repeated calling. If I understand the Win32 API docs correctly, calling ShowCursor(0) / ShowCursor(1) multiple times will decrement/increment a counter. Windows will show the cursor only if the counter is >= 0. This can also happen with my current implementation if not used correctly. I think will introduce a flag that prevents from calling ShowCursor(0) or ShowCursor(1) again if it already has been called.
Sounds good. Looking forward to the PR.
I also realized that the pointer locking implementation on Windows has room for improvement. I implemented a knob with it (also for an audio application) and it's way too sensitive.
alexvoina commentedon Nov 13, 2023
alright! thanks for the response, that makes sense. I'm glad to hear I'm not the only one building a desktop audio app with Flutter. I'd be curious to see what you're working on :D
I'll keep you posted about the PR
flutter-triage-bot commentedon Jun 7, 2024
The
triaged-desktoplabel is irrelevant if there is noteam-desktoplabel orfyi-desktoplabel.helgoboss commentedon Jan 12, 2025
@alexvoina I gave https://github.com/helgoboss/pointer_lock a revamp. It now supports a free mode in which any event can lock or unlock the pointer (see new README). There are a few other improvements as well, such as Linux support (X11), a smaller API surface and a dedicated widget for implementing the popular "lock while drag" use case.
alexvoina commentedon Jan 13, 2025
@helgoboss that's cool! I'll have a look and try to update. Your package still powers my app to this day, making real users happy so thank you for your work!
CodeDoctorDE commentedon Jun 26, 2026
Hi,
On the windows side it already captures the mouse button if its primary.
I'm making a contribution to also allow other mouse buttons to be captured on windows: #188394.
Add the mouse_capture plugin: relative pointer deltas on macOS
[web] Capture pointers to the Flutter view so drags survive platform …
[web] Capture pointers to the Flutter view so drags survive platform …