feat: drive the reader with a D-pad
This commit is contained in:
parent
7b2ddc0249
commit
f386ef2c5b
5 changed files with 600 additions and 84 deletions
|
|
@ -29,21 +29,24 @@ class _AddressBarState extends State<AddressBar> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focus.addListener(() {
|
||||
if (_focus.hasFocus != _focused) {
|
||||
setState(() => _focused = _focus.hasFocus);
|
||||
if (_focused) {
|
||||
_controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: _controller.text.length,
|
||||
);
|
||||
}
|
||||
_focus.addListener(_onFocusChange);
|
||||
}
|
||||
|
||||
void _onFocusChange() {
|
||||
if (_focus.hasFocus != _focused) {
|
||||
setState(() => _focused = _focus.hasFocus);
|
||||
if (_focused) {
|
||||
_controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: _controller.text.length,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focus.removeListener(_onFocusChange);
|
||||
// A focus node handed in from outside belongs to whoever handed it in.
|
||||
if (widget.focusNode == null) _focus.dispose();
|
||||
_controller.dispose();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue