Skip to content

[Flutter Desktop] Textfield does not accept accents #75510

Closed
flutter-team-archive/engine
#27921

Description

@Bestfastfire

On the desktop when I try to insert a letter with accents it looks as if I had pressed the button 2 times.

Ex:

~ + a = ã
~~ = ~~

But what is happening is:
~ + a = ~~ a

What happens:
Gravar_2021_02_05_12_33_38_532

What should happen:
Gravar_2021_02_05_12_33_55_241

Code example:

TextField(
     controller: TextEditingController())

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, 1.26.0-17.2.pre, on Microsoft Windows [versão 10.0.19042.746], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.3)
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.52.1)
[√] Connected device (3 available)

• No issues found!

Edit:

Im using logitech k380 (en_US format) and typing pt_BR, I tried do this with virtual keyboard and works well. Probably the problem is because the keyboard is in the en_US standard and my pc is set to type pt_BR.

Activity

  1. Bestfastfire commented on Feb 5, 2021

    @Bestfastfire
    Author

    An alternative solution until this is fixed, is to put in onChanged to identify ~~a or ^^e etc. And replace text in the controller with the correct one, ex:

    onChanged: (v) {
        if (v.contains('~~a') {
             controller.text = v.replaceAll('~~a', 'ã');
    
        }
    }
    

    With regex I will make a better solution than comparing with all possible accents.

  2. added
    a: text inputEntering text in a text field or keyboard related problems
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Feb 5, 2021
  3. HansMuller commented on Feb 5, 2021

    @HansMuller
    Contributor
  4. added
    P2Important issues not at the top of the work list
    on Feb 5, 2021
  5. cbracken commented on Feb 5, 2021

    @cbracken
    Member
  6. cbracken commented on Feb 5, 2021

    @cbracken
    Member

    @Bestfastfire thanks for filing! Would you mind adding detailed repro steps for this? Specifically, which keyboard/language settings are you using? Looks like your input method/keyboard are configured with ~ and ^ as dead keys, and then you type ~a or ^e to get ã and ê respectively?

  7. Bestfastfire commented on Feb 5, 2021

    @Bestfastfire
    Author

    @Bestfastfire thanks for filing! Would you mind adding detailed repro steps for this? Specifically, which keyboard/language settings are you using? Looks like your input method/keyboard are configured with ~ and ^ as dead keys, and then you type ~a or ^e to get ã and ê respectively?

    Im using logitech k380 with lang pt_BR

  8. Bestfastfire commented on Feb 5, 2021

    @Bestfastfire
    Author

    @Bestfastfire thanks for filing! Would you mind adding detailed repro steps for this? Specifically, which keyboard/language settings are you using? Looks like your input method/keyboard are configured with ~ and ^ as dead keys, and then you type ~a or ^e to get ã and ê respectively?

    I tried with virtual keyboard and works well. Now that you mention it, I think the problem may be due to alternative keyboards since the k380 is in the en_US format and I'm trying to pt_BR.

  9. cbracken commented on Feb 5, 2021

    @cbracken
    Member

    Thanks! Can you confirm whether this started recently or whether it's always been an issue for you? There have been two major Windows keyboard input related changes recently: one that deals with individual key events, another that adds support for CJK input via IMEs, either of which I could imagine impacting multi-key character input.

  10. Bestfastfire commented on Feb 5, 2021

    @Bestfastfire
    Author

    Thanks! Can you confirm whether this started recently or whether it's always been an issue for you? There have been two major Windows keyboard input related changes recently: one that deals with individual key events, another that adds support for CJK input via IMEs, either of which I could imagine impacting multi-key character input.

    Sorry, I didn't notice before, I just noticed it today.

  11. cbracken commented on Feb 5, 2021

    @cbracken
    Member

    No problem -- thanks for filing the issue. Will take a look!

  12. 5 remaining items

  13. ReniDelonzek commented on Apr 19, 2021

    @ReniDelonzek

    I have the same problem, it was introduced in the last beta version (2.1.0-12.2.pre), the problem only occurs on windows, on MACOS it works correctly

  14. eduardo-cervantes commented on Apr 20, 2021

    @eduardo-cervantes

    Any predictions for solving this problem, or do you have any workarounds?

  15. alberteije commented on Apr 23, 2021

    @alberteije

    It seems there is no solution for now?

  16. Bestfastfire commented on Apr 24, 2021

    @Bestfastfire
    Author

    It seems there is no solution for now?

    So far nothing, I am using the latest stable version of the flutter the bug continues, but it is only on this specific keyboard that I reported, it is in the EN_US standard and on windows it is set to PT_BR.

    I tested it on a keyboard that is PT_BR and it worked normally

  17. alberteije commented on Apr 24, 2021

    @alberteije

    It seems there is no solution for now?

    So far nothing, I am using the latest stable version of the flutter the bug continues, but it is only on this specific keyboard that I reported, it is in the EN_US standard and on windows it is set to PT_BR.

    I tested it on a keyboard that is PT_BR and it worked normally

    Interesting, my keyboard is PT_BR (brazilian laptop) and it doesn't work. I have exactly the problem you mentioned early.

  18. pablohls commented on Apr 24, 2021

    @pablohls

    It seems there is no solution for now?

    So far nothing, I am using the latest stable version of the flutter the bug continues, but it is only on this specific keyboard that I reported, it is in the EN_US standard and on windows it is set to PT_BR.
    I tested it on a keyboard that is PT_BR and it worked normally

    Interesting, my keyboard is PT_BR (brazilian laptop) and it doesn't work. I have exactly the problem the you mentioned early.

    The same for me.

  19. alycwb commented on Jun 15, 2021

    @alycwb

    I have an entire application developed, but I can't release it to production because of this issue. Any ETA to fix this bug?

  20. ReniDelonzek commented on Jun 16, 2021

    @ReniDelonzek

    If anyone needs an urgent fix to release (since the bug has been around for a long time and an official fix hasn't been released yet), I've made this ugly fix so it can work. I created a custom input and replaced it with the default one, then added that to my onChange.

    if (UtilsPlatform.isWindows) {
        int pos = controller.selection.start;
        String newValue = value
            // A
            .replaceAll('´´a', 'á')
            .replaceAll('``a', 'à')
            .replaceAll('^^a', 'â')
            .replaceAll('~~a', 'ã')
            .replaceAll('´´A', 'Á')
            .replaceAll('``A', 'À')
            .replaceAll('^^A', 'Â')
            .replaceAll('~~A', 'Ã')
            // E
            .replaceAll('´´e', 'é')
            .replaceAll('``e', 'è')
            .replaceAll('^^e', 'ê')
            .replaceAll('´´E', 'É')
            .replaceAll('``E', 'È')
            .replaceAll('^^E', 'Ê')
            // I
            .replaceAll('´´i', 'í')
            .replaceAll('``i', 'ì')
            .replaceAll('^^i', 'î')
            .replaceAll('´´I', 'Í')
            .replaceAll('``I', 'Ì')
            .replaceAll('^^I', 'î')
            // O
            .replaceAll('´´o', 'ó')
            .replaceAll('``o', 'ò')
            .replaceAll('^^o', 'ô')
            .replaceAll('~~o', 'õ')
            .replaceAll('´´O', 'Ó')
            .replaceAll('``O', 'Ò')
            .replaceAll('^^O', 'Ô')
            .replaceAll('~~O', 'Õ')
            // U
            .replaceAll('´´u', 'ú')
            .replaceAll('``u', 'ù')
            .replaceAll('^^u', 'û')
            .replaceAll('´´U', 'Ú')
            .replaceAll('``U', 'Ù')
            .replaceAll('^^U', 'Û');
    
        /// Makes the cursor stay in the correct place
        pos -= (value.length - newValue.length);
        if (pos > newValue.length) {
          pos = newValue.length;
        }
        controller.selection =
            TextSelection.fromPosition(TextPosition(offset: pos));
        onChanged(newValue);
      } else {
        onChanged(value);
      }
    

    It's not the best solution, and I haven't checked every possible character with accents, but it works fine for me.

  21. alycwb commented on Jun 16, 2021

    @alycwb

    Tks ReniDelonzek, I will try that!

  22. SalahAdDin commented on Jun 17, 2021

    @SalahAdDin

    I'm having this bug with mobile applications.

  23. marcoprodata commented on Jul 22, 2021

    @marcoprodata

    Any news about this bug?

  24. nero-angela commented on Jul 24, 2021

    @nero-angela
    Contributor

    I'm having this bug with mobile applications.

    mobile also has this issue. #59541

  25. github-actions commented on Aug 25, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  26. locked as resolved and limited conversation to collaborators on Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesplatform-windowsBuilding on or for Windows specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions