Repository navigation
PanGestureRecognizer with non-primary button gets cancelled when dragging out of the window #166309
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: mouseIssues related to using a mouse or mouse supportIssues related to using a mouse or mouse supportf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31Found to occur in 3.31frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
- Run as Windows Application
- Press middle mouse button on the blue container
- Hold and drag it out of the application window
Expected results
The gesture recognizer still receives updates when dragging out of the window until the mouse button is released
Actual results
The gesture recognizer invokes onEnd immediately after dragging it out of the window
This does not happen with primary mouse button, when using primary mouse button, the gesture recognizer still receives pointer update even when the cursor is no longer inside the application window.
Code sample
Code sample
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main(List<String> args) {
runApp(MaterialApp(home: Test()));
}
class Test extends StatelessWidget {
const Test({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: RawGestureDetector(
gestures: {
PanGestureRecognizer:
GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>(
() => PanGestureRecognizer(
debugOwner: this,
allowedButtonsFilter: (buttons) {
//return buttons & kTertiaryButton != 0;
return true;
},
),
(PanGestureRecognizer instance) {
instance.onStart = (details) {
print('onStart: ${details.globalPosition}');
};
instance.onUpdate = (details) {
print('onUpdate: ${details.globalPosition}');
};
instance.onEnd = (details) {
print('onEnd: ${details.globalPosition}');
};
instance.onCancel = () {
print('onCancel');
};
},
),
},
behavior: HitTestBehavior.deferToChild,
child: Center(
child: Container(width: 100, height: 100, color: Colors.blue),
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.29.2, on Microsoft Windows [Version 10.0.22631.5039], locale en-ID) [382ms]
• Flutter version 3.29.2 on channel stable at D:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c236373904 (3 weeks ago), 2025-03-13 16:17:06 -0400
• Engine revision 18b71d647a
• Dart version 3.7.2
• DevTools version 2.42.3
[√] Windows Version (11 Home Single Language 64-bit, 23H2, 2009) [1,982ms]
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [352ms]
• Android SDK at D:/Android/Sdk
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/to/windows-android-setup for more details.
[√] Chrome - develop for the web [224ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.31) [223ms]
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.11.34114.132
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2024.1) [18ms]
• Android Studio at D:\Program Files\Android\Android Studio2
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
[√] IntelliJ IDEA Ultimate Edition (version 2024.2) [17ms]
• IntelliJ at D:\Program Files\JetBrains\IntelliJ IDEA 2024.2
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
[√] Connected device (3 available) [161ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.5039]
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.178
• Edge (web) • edge • web-javascript • Microsoft Edge 134.0.3124.93
[√] Network resources [379ms]
• All expected network resources are available.
! Doctor found issues in 1 category.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: mouseIssues related to using a mouse or mouse supportIssues related to using a mouse or mouse supportf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31Found to occur in 3.31frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyBuilding on or for Windows specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
danagbemava-nc commentedon Apr 1, 2025
Reproducible using the code sample and steps provided above. This worked as expected on macOS. It most likely might be due to how lifecycle events are handled on windows. Labeling for further investigation
flutter doctor -v
CodeDoctorDE commentedon Jun 23, 2026
I think that's exactly the issues for me. I'm working on a fix and contribute it if its working :)
Fix non primary buttons not being captured on windows (flutter#188394)
github-actions commentedon Aug 6, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.