Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointerUpEvent.buttons needs to document what it represents more clearly #110448

Open
cswxzx opened this issue Aug 29, 2022 · 7 comments
Open

PointerUpEvent.buttons needs to document what it represents more clearly #110448

cswxzx opened this issue Aug 29, 2022 · 7 comments
Labels
a: desktop Running on desktop a: mouse Issues related to using a mouse or mouse support d: api docs Issues with https://api.flutter.dev/ found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team

Comments

@cswxzx
Copy link

cswxzx commented Aug 29, 2022

When the right mouse button is pressed, the buttons in PointerDownEvent are kSecondaryMouseButton, but the buttons in PointerUpEvent are kPrimaryMouseButton.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.1.0-0.0.pre.2268, on Ubuntu 20.04.4 LTS 5.15.0-46-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
[✓] VS Code (version 1.70.2)
@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Aug 29, 2022
@exaby73
Copy link
Member

exaby73 commented Aug 29, 2022

Hi @cswxzx please provide a minimal, reproducible example and the output of flutter doctor -v.

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 29, 2022
@cswxzx
Copy link
Author

cswxzx commented Sep 7, 2022

Correct the error description:
When the right mouse button is pressed, the buttons in PointerDownEvent are kSecondaryMouseButton, but the buttons in PointerUpEvent are 0.

kPrimaryMouseButton is same problem.

flutter doctor -v
[✓] Flutter (Channel master, 3.1.0-0.0.pre.2268, on Ubuntu 20.04.5 LTS 5.15.0-46-generic, locale en_US.UTF-8)
    • Flutter version 3.1.0-0.0.pre.2268 on channel master at /home/csw/work/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 97901da149 (3 weeks ago), 2022-08-14 01:53:54 -0700
    • Engine revision 83771593cb
    • Dart version 2.19.0 (build 2.19.0-96.0.dev)
    • DevTools version 2.16.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/csw/Android/Sdk
    • Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
    • ANDROID_HOME = /home/csw/Android/Sdk
    • ANDROID_SDK_ROOT = /home/csw/Android/Sdk
    • Java binary at: /home/csw/work/app/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.21.2
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /home/csw/work/app/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at /home/csw/work/app/idea-IU-221.5921.22
    • 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

[✓] VS Code (version 1.71.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.48.0

[✓] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 7.0 (API 24) (emulator)
    • Linux (desktop)                    • linux         • linux-x64      • Ubuntu 20.04.5 LTS 5.15.0-46-generic
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 105.0.5195.102

HTTP Host availability check is taking a long time...[!] HTTP Host Availability
    ✗ HTTP host "https://maven.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: Connection timed out
    ✗ HTTP host "https://cloud.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: Connection timed out

! Doctor found issues in 1 category.
Code Sample
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        backgroundColor: const Color(0xFF181818),
      ),
      body: Listener(
          //behavior: HitTestBehavior.opaque,
          onPointerDown: (PointerDownEvent event) {
            if (event.buttons == kPrimaryMouseButton) {
              print('##############, onPointerDown, kPrimaryMouseButton');
            } else if (event.buttons == kSecondaryMouseButton) {
              print('##############, onPointerDown, kSecondaryMouseButton');
            } else {
              print('##############, onPointerDown, button=${event.buttons}');
            }
          },
          onPointerUp: (PointerUpEvent event) {
            if (event.buttons == kPrimaryMouseButton) {
              print('##############, onPointerUp, kPrimaryMouseButton');
            } else if (event.buttons == kSecondaryMouseButton) {
              print('##############, onPointerUp, kSecondaryMouseButton');
            } else {
              print('##############, onPointerUp, button=${event.buttons}');
            }
          },
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: const <Widget>[
                Text(
                  'You have pushed the button this many times:',
                ),
              ],
            ),
          )),
      floatingActionButton: const FloatingActionButton(
        onPressed: null,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
Logs
flutter: ##############, onPointerDown, kPrimaryMouseButton
flutter: ##############, onPointerUp, button=0
flutter: ##############, onPointerDown, kSecondaryMouseButton
flutter: ##############, onPointerUp, button=0

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 7, 2022
@exaby73
Copy link
Member

exaby73 commented Sep 7, 2022

I can see you're using an older version of Flutter. Could you upgrade to the latest master and confirm if the issue still persists?

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 7, 2022
@cswxzx
Copy link
Author

cswxzx commented Sep 13, 2022

Flutter doctor (Master)
[✓] Flutter (Channel master, 3.4.0-19.0.pre.221, on Ubuntu 20.04.5 LTS 5.15.0-46-generic, locale
    en_US.UTF-8)
    • Flutter version 3.4.0-19.0.pre.221 on channel master at /home/csw/work/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision bbc42632a0 (3 hours ago), 2022-09-13 02:52:39 -0400
    • Engine revision 443b3646f8
    • Dart version 2.19.0 (build 2.19.0-191.0.dev)
    • DevTools version 2.17.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/csw/Android/Sdk
    • Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
    • ANDROID_HOME = /home/csw/Android/Sdk
    • ANDROID_SDK_ROOT = /home/csw/Android/Sdk
    • Java binary at: /home/csw/work/app/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.21.2
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /home/csw/work/app/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at /home/csw/work/app/idea-IU-221.5921.22
    • 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

[✓] VS Code (version 1.71.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.48.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.5 LTS 5.15.0-46-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 105.0.5195.102

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
Logs
flutter: ##############, onPointerDown, kPrimaryMouseButton
flutter: ##############, onPointerUp, button=0
flutter: ##############, onPointerDown, kSecondaryMouseButton
flutter: ##############, onPointerUp, button=0

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 13, 2022
@exaby73
Copy link
Member

exaby73 commented Sep 14, 2022

Tirage report

I can reproduce this issue on all desktop platforms as well as web. From the source, looks like 0 is a default value in the constructor of the PointerUpEvent. The buttons variable seems to not be set on onPointerUp.

Vesions reproducible on

  • Stable (3.3.1)
  • Master (3.4.0-19.0.pre.246)

Info

Code Sample
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

void main() => runApp(
      const MaterialApp(
        home: IndexPage(title: 'Demo'),
      ),
    );

class IndexPage extends StatefulWidget {
  const IndexPage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        backgroundColor: const Color(0xFF181818),
      ),
      body: Listener(
        //behavior: HitTestBehavior.opaque,
        onPointerDown: (PointerDownEvent event) {
          if (event.buttons == kPrimaryMouseButton) {
            print('##############, onPointerDown, kPrimaryMouseButton');
          } else if (event.buttons == kSecondaryMouseButton) {
            print('##############, onPointerDown, kSecondaryMouseButton');
          } else {
            print('##############, onPointerDown, button=${event.buttons}');
          }
        },
        onPointerUp: (PointerUpEvent event) {
          if (event.buttons == kPrimaryMouseButton) {
            print('##############, onPointerUp, kPrimaryMouseButton');
          } else if (event.buttons == kSecondaryMouseButton) {
            print('##############, onPointerUp, kSecondaryMouseButton');
          } else {
            print('##############, onPointerUp, button=${event.buttons}');
          }
        },
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: const <Widget>[
              Text(
                'You have pushed the button this many times:',
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: const FloatingActionButton(
        onPressed: null,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
Logs
##############, onPointerDown, kPrimaryMouseButton
##############, onPointerUp, button=0
##############, onPointerDown, kSecondaryMouseButton
##############, onPointerUp, button=0

Flutter Doctor (Windows)

flutter doctor -v (Stable)
[✓] Flutter (Channel stable, 3.3.1, on Microsoft Windows [Version 10.0.22000.918], locale en-US)
    • Flutter version 3.3.1 on channel stable at C:\Users\Nabeel\fvm\versions\stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4f9d92fbbd (7 days ago), 2022-09-06 17:54:53 -0700
    • Engine revision 3efdf03e73
    • Dart version 2.18.0
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\android-sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.3.32819.101
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 11.0.12+7-b1504.28-7817840)

[✓] VS Code (version 1.71.0)
    • VS Code at C:\Users\Nabeel\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[✓] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.918]
    • Chrome (web)                 • chrome        • web-javascript • unknown
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 105.0.1343.27

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
flutter doctor -v (Master)
[✓] Flutter (Channel master, 3.4.0-19.0.pre.246, on Microsoft Windows [Version 10.0.22000.918], locale en-US)
    • Flutter version 3.4.0-19.0.pre.246 on channel master at C:\Users\Nabeel\fvm\versions\master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e805237015 (2 hours ago), 2022-09-14 00:38:27 -0400
    • Engine revision 650defdd1a
    • Dart version 2.19.0 (build 2.19.0-196.0.dev)
    • DevTools version 2.17.0

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\android-sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.3.32819.101
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 11.0.12+7-b1504.28-7817840)

[✓] VS Code (version 1.71.0)
    • VS Code at C:\Users\Nabeel\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[✓] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.918]
    • Chrome (web)                 • chrome        • web-javascript • unknown
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 105.0.1343.27

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@exaby73 exaby73 added framework flutter/packages/flutter repository. See also f: labels. a: desktop Running on desktop a: mouse Issues related to using a mouse or mouse support has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 labels Sep 14, 2022
@exaby73 exaby73 changed the title linux PointerUpEvent buttons state incorrect PointerUpEvent buttons state is incorrect on Listener Sep 14, 2022
@exaby73 exaby73 changed the title PointerUpEvent buttons state is incorrect on Listener PointerUpEvent.buttons state is incorrect on Listener Sep 14, 2022
@exaby73 exaby73 removed the in triage Presently being triaged by the triage team label Sep 14, 2022
@gspencergoog gspencergoog added the P2 Important issues not at the top of the work list label Sep 15, 2022
@gspencergoog
Copy link
Contributor

(Desktop Triage) We think the problem here is one of documentation. The buttons field is meant to show the buttons that are currently pressed, and on button up, they are no longer pressed. We should probably document that more clearly.

@gspencergoog gspencergoog changed the title PointerUpEvent.buttons state is incorrect on Listener PointerUpEvent.buttons needs to document what it represents more clearly Sep 15, 2022
@cswxzx
Copy link
Author

cswxzx commented Sep 16, 2022

I think buttons should represent which button, whether it's pressed or popped.
In addition, the down member of PointerEvent has indicated whether it is pressed or popped up.

@flutter-triage-bot flutter-triage-bot bot added the d: api docs Issues with https://api.flutter.dev/ label Jul 5, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team labels Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop a: mouse Issues related to using a mouse or mouse support d: api docs Issues with https://api.flutter.dev/ found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team
Projects
None yet
Development

No branches or pull requests

4 participants