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

Same key triggered after some time (Android Chromebook) #1

Open
hotlittlewhitedog opened this issue May 14, 2024 · 1 comment
Open

Comments

@hotlittlewhitedog
Copy link

hotlittlewhitedog commented May 14, 2024

Hi all,

I tried your hotkey manager in an Android Chromebook emulator, it works some minutes and after without reason or errors, it doesn't work anymore. A last key pressed in my configuration (example KeyB) is triggered all the time even I push any key, even keys not registered in the config as KeyQ.

Rem: Maybe I have to put your widget on top of the Scaffold, please let me know.
Rem2: I'm always in the same instance of the desktop app.
Rem3: the app works perfectly without a key manager.

Thanks for any help :)

bool _canPop() => Navigator.of(homePageContext).canPop();

...
final Widget body = Container(
      child: ListView(
        controller: chapterTextScrollController,
        padding: EdgeInsets.only(left: 15.0, top: 0.0, right: 15.0, bottom: 0.0),
        shrinkWrap: false,
        physics: const AlwaysScrollableScrollPhysics(),
        children: [
          Container(
            padding: EdgeInsets.zero,
            child: Column(
              children: [
                scrollTab,
                chapterTitle,
                GestureDetector(
                  onHorizontalDragEnd: (details) => _onHorizontalDragEnd(details),
                  child: ChapterWidget(bbNames: gbbNames, chapterType: chapterType, lstChapterObject: chapterObject, colCount: gcolCount),
                ),
              ],
            ),
          ),
        ],
      ),
    );
return Scaffold(
      key: scaffoldKey,
      drawer: drawer,
      appBar: appBar,
      body: GHK.GalacticHotkeys<ShortcutKeys>(
        shortcuts: {
          ShortcutKeys.ESC:   [[LogicalKeyboardKey.escape]],
          ShortcutKeys.LEFT:  [[LogicalKeyboardKey.arrowLeft]],
          ShortcutKeys.RIGHT: [[LogicalKeyboardKey.arrowRight]],
          ShortcutKeys.M:     [[LogicalKeyboardKey.keyM]],
          ShortcutKeys.TAB:   [[LogicalKeyboardKey.tab]],
          ShortcutKeys.S:     [[LogicalKeyboardKey.keyS]],
          ShortcutKeys.F:     [[LogicalKeyboardKey.keyF]],
          ShortcutKeys.B:     [[LogicalKeyboardKey.keyB]],
          ShortcutKeys.A:     [[LogicalKeyboardKey.keyA]],
          ShortcutKeys.P:     [[LogicalKeyboardKey.keyP]],
        },
        onShortcutPressed: (ShortcutKeys identifier, List<LogicalKeyboardKey> pressedKeys)
        {
          print("Shortcut pressed: ${identifier.toString()}");

          switch (identifier) {
            case ShortcutKeys.ESC: {
              //Never block the ESC key
              if (_canPop()) Navigator.of(homePageContext).pop();
              break;
            }
            case ShortcutKeys.LEFT: {
              if (_canPop()) return; //Block the key
              _onClickBtnChapterLeft();
              break;
            }
            case ShortcutKeys.RIGHT: {
              if (_canPop()) return; //Block the key
              _onClickBtnChapterRight();
              break;
            }
            case ShortcutKeys.M: {
              if (_canPop()) return; //Block the key
              if (scaffoldKey.currentState != null && scaffoldKey.currentState!.hasDrawer) scaffoldKey.currentState?.openDrawer();
              break;
            }
            case ShortcutKeys.TAB: {
              if (_canPop()) return; //Block the key
              _onShowHistMenu(homePageContext, mnuHistoryValue);
              break;
            }
            case ShortcutKeys.S: {
              if (_canPop()) return; //Block the key
              _onShowSearchMenu(homePageContext, mnuSearchValue);
              break;
            }
            case ShortcutKeys.F: {
              if (_canPop()) return; //Block the key
              //TODO: search F
              _onShowSearchMenu(homePageContext, mnuSearchValue);
              break;
            }
            case ShortcutKeys.B: {
              if (_canPop()) return; //Block the key
              _onShowBooksMenu(homePageContext);
              break;
            }
            case ShortcutKeys.P: {
              if (_canPop()) return; //Block the key
              _onShowPrblsMenu(homePageContext, mnuPrblsValue);
              break;
            }
            case ShortcutKeys.A: {
              if (_canPop()) return; //Block the key
              _onShowArtsMenu(homePageContext, mnuArtsValue);
              break;
            }
            default:
              break;
          }
        },
        child: body,
      ),
    );

`[✓] Flutter (Channel stable, 3.19.6, on macOS 14.2.1 23C71 darwin-x64, locale en-BE)
• Flutter version 3.19.6 on channel stable at /Users/xxx/AndroidStudioProjects/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (4 weeks ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/xxx/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/xxx/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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.10+0-17.0.10b1087.21-11572160)

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.2.1 23C71 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.201
`

@juarezfranco
Copy link
Contributor

Did you try Maybe I have to put your widget on top of the Scaffold, please let me know. ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants