Skip to content

Text Editing Shortcuts/Intents/Actions #75004

Closed

Description

@justinmc

Currently, user events related to text editing are handled by a bunch of disparate code that could be consolidated. For example, there is a RawKeyboard listener in RenderEditable in addition to our built-in keyboard Shortcuts system.

Key events should be consolidated into Shortcuts. Mouse, tap, and other events should dispatch Intents that are handled the same way that the keyboard Intents are handled.

Related:
#30725
#57679
#101151

Activity

  1. self-assigned this
    on Jan 29, 2021
  2. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jan 29, 2021
  3. justinmc commented on Feb 13, 2021

    @justinmc
    ContributorAuthor

    When we've got some mouse/tap Actions being overridden, then an example of overriding these should be added to TextEditingActions. I've removed the original one I had there for now.

    Code
    ///
    /// {@tool snippet}
    ///
    /// This example shows how to use an additional [Actions] widget to override
    /// the left arrow key [Intent] and make it move the cursor to the right
    /// instead.
    ///
    /// ```dart
    /// final TextEditingController controller = TextEditingController(
    ///   text: "Try using the keyboard's arrow keys and notice that left moves right.",
    /// );
    ///
    /// @override
    /// Widget build(BuildContext context) {
    ///   return Scaffold(
    ///     body: Center(
    ///       child: Actions(
    ///         actions: <Type, Action<Intent>>{
    ///           ArrowLeftTextIntent: TextEditingAction<ArrowLeftTextIntent>(
    ///             onInvoke: (ArrowLeftTextIntent intent, EditableTextState editableTextState) {
    ///               editableTextState.renderEditable.moveSelectionRight(SelectionChangedCause.keyboard);
    ///             },
    ///           ),
    ///         },
    ///         child: TextField(
    ///           controller: controller,
    ///         ),
    ///       ),
    ///     ),
    ///   );
    /// }
    /// ```
    /// {@end-tool}
  4. justinmc commented on Mar 12, 2021

    @justinmc
    ContributorAuthor

    We've now got a system for handling text editing interactions with Shortcuts/Intents/Actions: #75032

    For this issue to be complete, we still need:

  5. boyan01 commented on Jun 8, 2021

    @boyan01
    Contributor

    Does this Text Editing Shortcuts/Intents/Actions in composing input mode for other languages such as Japanese and Chinese has been considered?

    Background

    I am developing a flutter application with text input, However, it is found that the current TextField of flutter has serious experience problems on the macos platform in Chinese and Japanese input.

    Chinese and Japanese input methods will have a special place, they need to rely on multiple letters for combined input. which was named Compsing in flutter and MarkedText in macOS

    For example, in Chinese Pinyin - Simplified inpu mode

    when you typed letters n i in sequence, which a floating window will appear on theTextField with candidate text related to the letters which you just input(ni), and the first charater would be 你.

    This is an example of the video corresponding to the text input process described above.
    https://user-images.githubusercontent.com/17426470/121132488-c9ecf800-c863-11eb-9e41-ff32204b5de8.mov

    Current problem

    1. DeleteTextIntent did not support delete compsing text in macOS. [macOS] Backspace collapses composing region on macOS #78061
      SingleActivator(LogicalKeyboardKey.backspace): DeleteTextIntent(),
      SingleActivator(LogicalKeyboardKey.backspace, alt: true): DeleteByWordTextIntent(),
      SingleActivator(LogicalKeyboardKey.backspace, meta: true): DeleteByLineTextIntent(),
      SingleActivator(LogicalKeyboardKey.delete): DeleteForwardTextIntent(),
      SingleActivator(LogicalKeyboardKey.delete, alt: true): DeleteForwardByWordTextIntent(),
      SingleActivator(LogicalKeyboardKey.delete, meta: true): DeleteForwardByLineTextIntent(),
    2. the MoveSelectionDownTextIntent has intercepted arrow down key event during in composing state. As a result, the arrow up and arrow down keys cannot be used to expand the floating window for combined candidate text selection.
      SingleActivator(LogicalKeyboardKey.arrowDown): MoveSelectionDownTextIntent(),

    End

    I tried to solve the above problem by modifying the flutter engine. Although the problem was temporarily resolved. But I still hope that flutter's text input framework takes into account the composed text input processing from the beginning of its design , in this way can the flutter framework be more usable.

  6. justinmc commented on Jun 25, 2021

    @justinmc
    ContributorAuthor

    @boyan01 Thanks for the detailed comment! We are trying to ensure that composing keyboards work on all of Flutter's platforms. I can confirm that problem 2 is broken for me too. I've created an issue for it here: #85328

  7. justinmc commented on Oct 1, 2021

    @justinmc
    ContributorAuthor

    Unassigning myself as @LongCatIsLooong is the one working on bringing this to mouse/tap gestures.

  8. removed their assignment
    on Oct 1, 2021
  9. justinmc commented on Jul 13, 2022

    @justinmc
    ContributorAuthor

    I'm going to close this now that the only work remaining is captured by #101151.

  10. github-actions commented on Jul 27, 2022

    @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.

  11. locked as resolved and limited conversation to collaborators on Jul 27, 2022
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

    a: text inputEntering text in a text field or keyboard related problemsc: tech-debtTechnical debt, code quality, testing, etc.frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions