attempt to deal with focus problem in developer page

This commit is contained in:
Christien Rioux 2025-04-21 15:23:36 -04:00
parent db61908d09
commit 933a22122a

View file

@ -21,7 +21,7 @@ import '../../tools/tools.dart';
import 'history_text_editing_controller.dart';
final globalDebugTerminal = Terminal(
maxLines: 50000,
maxLines: 10000,
);
const kDefaultTerminalStyle = TerminalStyle(
@ -187,6 +187,15 @@ class _DeveloperPageState extends State<DeveloperPage> {
}
}
Future<void> _onSubmitCommand(String debugCommand) async {
final ok = await _sendDebugCommand(debugCommand);
if (ok) {
setState(() {
_historyController.submit(debugCommand);
});
}
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
@ -282,16 +291,17 @@ class _DeveloperPageState extends State<DeveloperPage> {
textStyle: kDefaultTerminalStyle,
controller: _terminalController,
keyboardType: TextInputType.none,
//autofocus: true,
backgroundOpacity: _showEllet ? 0.75 : 1.0,
onSecondaryTapDown: (details, offset) async {
await copySelection(context);
})
]).expanded(),
TextField(
TextFormField(
enabled: !_busy,
autofocus: true,
controller: _historyController.controller,
focusNode: _historyController.focusNode,
textInputAction: TextInputAction.send,
onTapOutside: (event) {
FocusManager.instance.primaryFocus?.unfocus();
},
@ -323,7 +333,7 @@ class _DeveloperPageState extends State<DeveloperPage> {
final debugCommand =
_historyController.controller.text;
_historyController.controller.clear();
await _sendDebugCommand(debugCommand);
await _onSubmitCommand(debugCommand);
},
)),
onChanged: (_) {
@ -334,17 +344,12 @@ class _DeveloperPageState extends State<DeveloperPage> {
_historyController.controller.clearComposing();
// don't give up focus though
},
onSubmitted: (debugCommand) async {
onFieldSubmitted: (debugCommand) async {
if (debugCommand.isEmpty) {
return;
}
final ok = await _sendDebugCommand(debugCommand);
if (ok) {
setState(() {
_historyController.submit(debugCommand);
});
}
await _onSubmitCommand(debugCommand);
_historyController.focusNode.requestFocus();
},
).paddingAll(4)
])));