fix using default onSubmit after tab tapped
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
ed441242bf
commit
9d4f899dfd
@ -632,6 +632,7 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
if (!scopeNode.hasFocus) scopeNode.requestFocus();
|
if (!scopeNode.hasFocus) scopeNode.requestFocus();
|
||||||
});
|
});
|
||||||
const double padding = 16;
|
const double padding = 16;
|
||||||
|
bool tabTapped = false;
|
||||||
return FocusScope(
|
return FocusScope(
|
||||||
node: scopeNode,
|
node: scopeNode,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
@ -641,13 +642,15 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
onCancel?.call();
|
onCancel?.call();
|
||||||
}
|
}
|
||||||
return KeyEventResult.handled; // avoid TextField exception on escape
|
return KeyEventResult.handled; // avoid TextField exception on escape
|
||||||
} else if (onSubmit != null &&
|
} else if (!tabTapped &&
|
||||||
|
onSubmit != null &&
|
||||||
key.logicalKey == LogicalKeyboardKey.enter) {
|
key.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
if (key is RawKeyDownEvent) onSubmit?.call();
|
if (key is RawKeyDownEvent) onSubmit?.call();
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
} else if (key.logicalKey == LogicalKeyboardKey.tab) {
|
} else if (key.logicalKey == LogicalKeyboardKey.tab) {
|
||||||
if (key is RawKeyDownEvent) {
|
if (key is RawKeyDownEvent) {
|
||||||
scopeNode.nextFocus();
|
scopeNode.nextFocus();
|
||||||
|
tabTapped = true;
|
||||||
}
|
}
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user