feat: add keyboard shortcuts and Tab link traversal on pointer hosts
This commit is contained in:
parent
fa7aa5557c
commit
56db479df0
6 changed files with 798 additions and 272 deletions
|
|
@ -11,7 +11,11 @@ import '../app.dart';
|
|||
/// subscribe (only when the page offers something to subscribe to) and
|
||||
/// bookmark the current page.
|
||||
class AddressBar extends StatefulWidget {
|
||||
const AddressBar({super.key});
|
||||
const AddressBar({this.focusNode, super.key});
|
||||
|
||||
/// The reader can ask for the field's focus from outside, for a keyboard
|
||||
/// shortcut. When null the bar owns its own node.
|
||||
final FocusNode? focusNode;
|
||||
|
||||
@override
|
||||
State<AddressBar> createState() => _AddressBarState();
|
||||
|
|
@ -19,7 +23,7 @@ class AddressBar extends StatefulWidget {
|
|||
|
||||
class _AddressBarState extends State<AddressBar> {
|
||||
final _controller = TextEditingController();
|
||||
final _focus = FocusNode();
|
||||
late final FocusNode _focus = widget.focusNode ?? FocusNode();
|
||||
bool _focused = false;
|
||||
|
||||
@override
|
||||
|
|
@ -40,7 +44,8 @@ class _AddressBarState extends State<AddressBar> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_focus.dispose();
|
||||
// A focus node handed in from outside belongs to whoever handed it in.
|
||||
if (widget.focusNode == null) _focus.dispose();
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue