Update some Focus docs (#87561)

This commit is contained in:
xubaolin 2021-08-04 09:25:05 +08:00 committed by GitHub
parent 536e7a2ec4
commit 5a48a416b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -309,11 +309,12 @@ enum UnfocusDisposition {
/// The [FocusManager] receives key events from [RawKeyboard] and
/// [HardwareKeyboard] and will pass them to the focused nodes. It starts with
/// the node with the primary focus, and will call the [onKey] or [onKeyEvent]
/// callback for that node. If the callback returns false, indicating that it did
/// not handle the event, the [FocusManager] will move to the parent of that node
/// and call its [onKey] or [onKeyEvent]. If that [onKey] or [onKeyEvent] returns
/// true, then it will stop propagating the event. If it reaches the root
/// [FocusScopeNode], [FocusManager.rootScope], the event is discarded.
/// callback for that node. If the callback returns [KeyEventResult.ignored],
/// indicating that it did not handle the event, the [FocusManager] will move
/// to the parent of that node and call its [onKey] or [onKeyEvent]. If that
/// [onKey] or [onKeyEvent] returns [KeyEventResult.handled], then it will stop
/// propagating the event. If it reaches the root [FocusScopeNode],
/// [FocusManager.rootScope], the event is discarded.
/// {@endtemplate}
///
/// ## Focus Traversal

View file

@ -16,7 +16,7 @@ import 'inherited_notifier.dart';
///
/// For keyboard events, [onKey] is called if [FocusNode.hasFocus] is true for
/// this widget's [focusNode], unless a focused descendant's [onKey] callback
/// returns true when called.
/// returns [KeyEventResult.handled] when called.
///
/// This widget does not provide any visual indication that the focus has
/// changed. Any desired visual changes should be made when [onFocusChange] is
@ -316,9 +316,9 @@ class Focus extends StatefulWidget {
/// focus.
///
/// Key events are first given to the [FocusNode] that has primary focus, and
/// if its [onKeyEvent] method return false, then they are given to each
/// ancestor node up the focus hierarchy in turn. If an event reaches the root
/// of the hierarchy, it is discarded.
/// if its [onKeyEvent] method returns [KeyEventResult.ignored], then they are
/// given to each ancestor node up the focus hierarchy in turn. If an event
/// reaches the root of the hierarchy, it is discarded.
///
/// This is not the way to get text input in the manner of a text field: it
/// leaves out support for input method editors, and doesn't support soft
@ -742,8 +742,9 @@ class _FocusState extends State<Focus> {
/// The [onKey] argument allows specification of a key event handler that is
/// invoked when this node or one of its children has focus. Keys are handed to
/// the primary focused widget first, and then they propagate through the
/// ancestors of that node, stopping if one of them returns true from [onKey],
/// indicating that it has handled the event.
/// ancestors of that node, stopping if one of them returns
/// [KeyEventResult.handled] from [onKey], indicating that it has handled the
/// event.
///
/// Managing a [FocusScopeNode] means managing its lifecycle, listening for
/// changes in focus, and re-parenting it when needed to keep the focus