最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

keyboard shortcuts - flutter webOS navigate with arrow key between widgets - Stack Overflow

programmeradmin0浏览0评论

I want to make webOS app with Flutter and use this app in TV, I have a List of items, consider 3 rows which are having 10 items each, and all scrollable, I want to move between them by keyboard and pressing arrow keys, like when I press arrow right it should go to next item, left previous item and when i press down it should start from the first item of the next list. the arrow right and left keys are working fine but arrow down and up are not working as expected. when I press arrow key down its going to closest item in direction down, which is a correct behaviour if its a grid view but not for the list which is my case.

I added the shortcuts to enable the arrow keys, I tried the custom policy but that did not work.

Till now i tried adding shortcuts inside MaterialApp :

shortcuts: {
        // Activation
        SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),
        SingleActivator(LogicalKeyboardKey.numpadEnter): ActivateIntent(),
        SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),
        SingleActivator(LogicalKeyboardKey.gameButtonA): ActivateIntent(),
        SingleActivator(LogicalKeyboardKey.select): ActivateIntent(),

        // Dismissal
        SingleActivator(LogicalKeyboardKey.escape): DismissIntent(),

        LogicalKeySet(LogicalKeyboardKey.arrowLeft): const DirectionalFocusIntent(
          TraversalDirection.left,
          ignoreTextFields: false,
        ),
        LogicalKeySet(LogicalKeyboardKey.arrowRight): const DirectionalFocusIntent(
          TraversalDirection.right,
          ignoreTextFields: false,
        ),
        LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(
          TraversalDirection.down,
          ignoreTextFields: false,
        ),
        LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(
          TraversalDirection.up,
          ignoreTextFields: false,
        ),
        LogicalKeySet(LogicalKeyboardKey.space): const ActivateIntent(),
      },

and also i tried to wrap my list with FocusTraversalGroup:

return FocusTraversalGroup(
            policy: ReadingOrderTraversalPolicy(),
            child: ListView(

I also tried WidgetOrderTraversalPolicy as a policy.
but neither of them worked to achieve my goal.

发布评论

评论列表(0)

  1. 暂无评论