flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.97k stars 27.18k forks source link

macOS : updateEditingValue is not getting called upon typing Chinese or Non-English language. #124966

Open jzhgithub18 opened 1 year ago

jzhgithub18 commented 1 year ago

Is there an existing issue for this?

Steps to reproduce

when i input Chinese word,updateEditingValue will not be callback, but when is english is normal. in windows platform is ok. and i propose has a function to set the position of Candidate Window

image

Expected results

image

Actual results

null

Code sample

Code sample ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: MyHomePage( title: 'Flutter Demo Home Page', focusNode: FocusNode(debugLabel: 'text page')), ); } } class MyHomePage extends StatefulWidget { MyHomePage({super.key, required this.title, this.focusNode}); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. // This class is the configuration for the state. It holds the values (in this // case the title) provided by the parent (in this case the App widget) and // used by the build method of the State. Fields in a Widget subclass are // always marked "final". final FocusNode? focusNode; final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State with TextInputClient { int _counter = 0; late double _pixelRatio; /// Max width of canvas late double maxWidth; /// Max height of canvas late double maxHeight; TextInputConnection? _textInputConnection; RawKeyboardListener? mouseAndGesture; void _openInputConnection() { var textStyle = TextStyle(fontSize: 14.0); print('_openInputConnection'); _textInputConnection = TextInput.attach( this, const TextInputConfiguration( inputType: TextInputType.multiline, inputAction: TextInputAction.none, readOnly: false, obscureText: false, enableDeltaModel: false, smartDashesType: SmartDashesType.enabled, smartQuotesType: SmartQuotesType.enabled, enableInteractiveSelection: false)); _textInputConnection! ..setStyle( fontFamily: textStyle.fontFamily, fontSize: textStyle.fontSize, fontWeight: textStyle.fontWeight, textDirection: TextDirection.ltr, textAlign: TextAlign.center) ..setEditingState(const TextEditingValue(text: '')); _textInputConnection?.show(); } void _incrementCounter() { if (widget.focusNode!.hasFocus) { _openInputConnection(); } else { // widget.focusNode?.requestFocus(); mouseAndGesture?.focusNode.requestFocus(); } } int? activePointerId; @override Widget build(BuildContext context) { final GestureDetector gestureDetector = GestureDetector( onVerticalDragUpdate: (DragUpdateDetails details) { //NO-OP }, child: Container( decoration: BoxDecoration(color: Colors.white), child: Listener( onPointerDown: (PointerDownEvent event) { if (activePointerId == null || activePointerId == event.pointer) { final Offset o = event.localPosition; activePointerId = event.pointer; } }, onPointerUp: (PointerUpEvent event) { if (activePointerId == event.pointer) { final Offset o = event.localPosition; } }, onPointerCancel: (PointerCancelEvent event) { if (activePointerId == event.pointer) {} }, onPointerMove: (PointerMoveEvent event) { if (activePointerId == event.pointer) { final Offset o = event.localPosition; } }, onPointerSignal: (pointerSignal) {}, onPointerHover: (PointerHoverEvent event) {}, child: Container( color: Colors.transparent, child: Texture(textureId: 0), ), ), ), ); mouseAndGesture = RawKeyboardListener( focusNode: FocusNode(), autofocus: false, onKey: (event) {}, child: MouseRegion( cursor: MouseCursor.defer, onEnter: (PointerEnterEvent event) { print('---mouse enter '); setState(() {}); }, onExit: (PointerExitEvent event) { print('---mouse onExit '); }, onHover: (PointerHoverEvent event) { final Offset o = event.localPosition; // print('---mouse HoverEvent $o '); }, child: gestureDetector, ), ); Widget wbp = IgnorePointer( ignoring: false, //是否事件穿透 child: LayoutBuilder(builder: ((context, constraints) { _pixelRatio = MediaQuery.of(context).devicePixelRatio; maxWidth = constraints.biggest.width; maxHeight = constraints.biggest.height; if (mouseAndGesture != null) { mouseAndGesture?.focusNode.addListener(_openInputConnection); } return mouseAndGesture ?? gestureDetector; }))); // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Column( // Column is also a layout widget. It takes a list of children and // arranges them vertically. By default, it sizes itself to fit its // children horizontally, and tries to be as tall as its parent. // // Invoke "debug painting" (press "p" in the console, choose the // "Toggle Debug Paint" action from the Flutter Inspector in Android // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) // to see the wireframe for each widget. // // Column has various properties to control how it sizes itself and // how it positions its children. Here we use mainAxisAlignment to // center the children vertically; the main axis here is the vertical // axis because Columns are vertical (the cross axis would be // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 900, height: 540, child: wbp, color: Colors.blue, ) ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } @override void connectionClosed() { // TODO: implement connectionClosed } @override // TODO: implement currentAutofillScope AutofillScope? get currentAutofillScope => throw UnimplementedError(); @override // TODO: implement currentTextEditingValue TextEditingValue? get currentTextEditingValue => throw UnimplementedError(); @override void performAction(TextInputAction action) { // TODO: implement performAction print('performPrivateCommand $performAction'); } @override void performPrivateCommand(String action, Map data) { // TODO: implement performPrivateCommand print('performPrivateCommand $action $data'); } @override void showAutocorrectionPromptRect(int start, int end) { // TODO: implement showAutocorrectionPromptRect print('showAutocorrectionPromptRect $start $end'); } @override void updateEditingValue(TextEditingValue value) { // TODO: implement updateEditingValue print('updateEditingValue $value'); } @override void updateFloatingCursor(RawFloatingCursorPoint point) { // TODO: implement updateFloatingCursor print('updateFloatingCursor $point'); } } ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console flutter: ---mouse enter flutter: ---mouse onExit flutter: _openInputConnection flutter: ---mouse enter flutter: ---mouse onExit flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)) flutter: ---mouse enter 2023-04-17 20:33:01.103 flutter_text_input_test[7111:1986259] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit 2023-04-17 20:33:01.340 flutter_text_input_test[7111:1986259] _TIPropertyValueIsValid called with 5 on nil context! 2023-04-17 20:33:01.340 flutter_text_input_test[7111:1986259] imkxpc_getApplicationProperty:reply: called with incorrect property value 5, bailing. 2023-04-17 20:33:01.340 flutter_text_input_test[7111:1986259] Text input context does not respond to _valueForTIProperty: 2023-04-17 20:33:01.341 flutter_text_input_test[7111:1986259] _TIPropertyValueIsValid called with 4 on nil context! 2023-04-17 20:33:01.341 flutter_text_input_test[7111:1986259] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2023-04-17 20:33:01.341 flutter_text_input_test[7111:1986259] Text input context does not respond to _valueForTIProperty: ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-x64, locale zh-Hans-CN) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.2) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [!] Android Studio (version 2022.1) ✗ Unable to find bundled Java version. [✓] VS Code (version 1.77.0) [✓] Connected device (2 available) [✓] HTTP Host Availability```
darshankawar commented 1 year ago

@jzhgithub18 Can you provide steps to replicate along with expected behavior as opposed to actual behavior ? Also, can you try the same on latest stable or master version and check if you still get same behavior or not ?

jzhgithub18 commented 1 year ago

the 'code sample' had been provide in above. you can to replicate.

  1. flutter run codesample.
  2. change to the chinese ime.
  3. Click on the plus sign button and use input method for Chinese input
  4. check the log there will have same error, and will not callback updateEditingValue with textEditingValue image

I checkout to master, the master version still get same behavior

darshankawar commented 1 year ago

Please check this issue and see if it is similar to your case.

jzhgithub18 commented 1 year ago

Two questions are different questions,my case is the Pinyin textinput but https://github.com/flutter/flutter/issues/82124 issue is the Function keys not work to cursor position.

darshankawar commented 1 year ago

Thanks for the update and patience. I ran the code sample using latest stable and found out below in console logs:

flutter: ---mouse onExit 
flutter: ---mouse enter 
flutter: ---mouse onExit 
2023-04-18 18:32:47.574 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 5 on nil context!
2023-04-18 18:32:47.574 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 5, bailing.
2023-04-18 18:32:47.574 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:47.575 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 4 on nil context!
2023-04-18 18:32:47.575 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2023-04-18 18:32:47.575 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 5 on nil context!
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 5, bailing.
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 4 on nil context!
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2023-04-18 18:32:47.577 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 5 on nil context!
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 5, bailing.
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 4 on nil context!
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2023-04-18 18:32:47.581 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
flutter: _openInputConnection
flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: _openInputConnection
flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
2023-04-18 18:32:55.628 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 4 on nil context!
2023-04-18 18:32:55.628 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2023-04-18 18:32:55.628 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
2023-04-18 18:32:55.629 enable_settings_issue[39152:303030] _TIPropertyValueIsValid called with 4 on nil context!
2023-04-18 18:32:55.629 enable_settings_issue[39152:303030] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2023-04-18 18:32:55.629 enable_settings_issue[39152:303030] Text input context does not respond to _valueForTIProperty:
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: ---mouse enter 
flutter: ---mouse onExit 

Is it same output as you are reporting ?

jzhgithub18 commented 1 year ago

Yes, it same output,and can try in English it can get normal updateEditingValue value.

darshankawar commented 1 year ago

Thanks for the update.

For English language, we get below console output which has updateEditingValue:

flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: _openInputConnection
flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: _openInputConnection
flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: ---mouse enter 
flutter: ---mouse onExit 
flutter: _openInputConnection
flutter: updateEditingValue TextEditingValue(text: ┤├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: ---mouse enter 
flutter: ---mouse onExit 

For Non-English, as stated https://github.com/flutter/flutter/issues/124966#issuecomment-1513094250

Looks like the behavior could be occuring due to https://github.com/flutter/flutter/issues/107462

stable, master flutter doctor -v ``` [!] Flutter (Channel stable, 3.7.11, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.7.11 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision f72efea43c (6 days ago), 2023-04-11 11:57:21 -0700 • Engine revision 1a65d409c7 • Dart version 2.19.6 • DevTools version 2.20.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.10.0-7.0.pre.44, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.10.0-7.0.pre.44 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision d9392f2e2a (4 hours ago), 2023-04-18 20:31:26 -0400 • Engine revision 099ed6c62d • Dart version 3.1.0 (build 3.1.0-12.0.dev) • DevTools version 2.23.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/dhs/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 65.1.4 • Dart plugin version 213.7228 [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 15.3.1 19D52 • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
Renzo-Olivares commented 1 year ago

cc @LongCatIsLooong from triage.

jzhgithub18 commented 1 year ago

Can we now know what is causing this problem?

flutter-triage-bot[bot] commented 3 months ago

The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

lucasjinreal commented 3 months ago

Same here.imkxpc_setApplicationProperty:value:reply: called with incorrect property value 12, bailing.

this caused me refreshed the UI unexpected. And everything typed in textfiled will be wiped out.