caduandrade/davi_flutter

Focus problem between instances (or simply another focus widget)

Closed this issue · 2 comments

Hello again, maybe I found a bug or I simply did something wrong.
To be sure, I reproduced my findings in a small windows test-app that contains nothing more than needed:

class TestDaviFocusProblems extends StatelessWidget {
const TestDaviFocusProblems({super.key});
@OverRide
Widget build(BuildContext context) {
return const Column(
children: [
Expanded(
child: DaviTableFromExample(),
),
Expanded(
child: DaviTableFromExample(),
),
],
);
}
}

This is the only widget in Scaffold.body and Scaffold is in MaterialApp.home.
The 'DaviTableFromExample' widgets are exactly whats on the Davi example page ( as class HomePage there).

Both tables are correctly shown one above the other.
Scrolling with mouse wheel works for each if the mouse cursor is within the table.
The Problem is about vertical scrolling with cursor keys (up/down):

  • when I set the focus via mouseclick in the upper table, I can scroll up with cursor-key-up.
    -- when i use cursor-key-down however, the focus switches to the lower table.
  • The same happens with the lower table, only with the opposite cursor keys and direction of course.

In another test I found, that there is no need for a second Davi instance at all. If there is an element that may have focus 'above' Davi, the up-key will move the focus there. If there is a focusable element 'below' Davi, the down-key will give it the focus.

Is this a bug or is there a way to control the focus behaviour or the key usage of Davi?
Thank you

Update: I now wrapped the Davi widget with 'Focus' and catched arrowDown and arrowUp keys in its onKey() handler by returning KeyEventResult.handled.
It works that way.
But should that not be handled inside Davi?