add requestChatInputFocus()

This commit is contained in:
csf 2023-02-02 21:39:25 +09:00
parent 1e9625045b
commit c6269b54af
2 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:dash_chat_2/dash_chat_2.dart';
import 'package:draggable_float_widget/draggable_float_widget.dart';
import 'package:flutter/material.dart';
@ -139,6 +141,7 @@ class ChatModel with ChangeNotifier {
});
overlayState.insert(overlay);
chatWindowOverlayEntry = overlay;
requestChatInputFocus();
}
hideChatWindowOverlay() {
@ -188,6 +191,7 @@ class ChatModel with ChangeNotifier {
await windowManager.setSizeAlignment(
kConnectionManagerWindowSize, Alignment.topRight);
} else {
requestChatInputFocus();
await windowManager.show();
await windowManager.setSizeAlignment(Size(600, 400), Alignment.topRight);
_isShowCMChatPage = !_isShowCMChatPage;
@ -292,4 +296,12 @@ class ChatModel with ChangeNotifier {
resetClientMode() {
_messages[clientModeID]?.clear();
}
void requestChatInputFocus() {
Timer(Duration(milliseconds: 100), () {
if (inputNode.hasListeners && inputNode.canRequestFocus) {
inputNode.requestFocus();
}
});
}
}

View File

@ -16,7 +16,7 @@ final testClients = [
Client(3, false, false, "UserDDDDDDDDDDDd", "441123123", true, false, false)
];
/// -t lib/cm_main.dart to test cm
/// flutter run -d {platform} -t lib/cm_test.dart to test cm
void main(List<String> args) async {
isTest = true;
WidgetsFlutterBinding.ensureInitialized();