Skip to content

Need a way to send synchronous keyboard events from embedder to Dart and get a response. #33521

Closed

Description

@gspencergoog

Internal: b/140830852

Similar to #28310, we need to be able to synchronously take keyboard events from the platform embedder, pass them to Dart to be handled, and if they are not handled, then pass them back to the platform to give it a chance to handle them.

This is needed so that add2app has a hope of working in environments with keyboards (like desktops), and so that we can capture keys before they get to a soft keyboard, as requested way back in #5986 (and has come up repeatedly).

We need a way to determine whether key events have been handled, synchronously, so that embedders know whether to continue propagating them in the native view hierarchy.

It needs to be synchronous because key events need to be responded to synchronously on host platforms.

Activity

  1. stuartmorgan-g commented on May 29, 2019

    @stuartmorgan-g
    Contributor

    Relatedly, there have been general conversations several times in the past about the need for a formal keyboard API in embedding.h, rather than passing text input and key events via a platform channel.

  2. added
    engineflutter/engine related. See also e: labels.
    and removed on Jul 26, 2019
  3. added this to the milestone on Aug 13, 2019
  4. jkurtw commented on Sep 10, 2019

    @jkurtw

    b/140830852

  5. modified the milestones: , April 2020 on Jan 29, 2020
  6. jwinarske commented on Apr 10, 2020

    @jwinarske
    Contributor

    I have a Wayland Embedder client working with the exception of Keyboard. I send key events, and they're dropped by the engine. It looks like I need to modify the Engine to register a "flutter/keyevent" handler. Will this change enable a default channel in the embedder for keyevents?

  7. stuartmorgan-g commented on Apr 10, 2020

    @stuartmorgan-g
    Contributor

    It looks like I need to modify the Engine to register a "flutter/keyevent" handler.

    The listener is in the framework code, and is always present. You should not need to modify the engine.

    Will this change enable a default channel in the embedder for keyevents?

    No (per above), but it will provide an explicit API in embedder.h that embedders should use instead of the message channel.

  8. modified the milestones: April 2020, on May 5, 2020
  9. modified the milestones: , December 2020 on May 6, 2020
  10. added
    P1High-priority issues at the top of the work list
    on May 29, 2020
  11. Sunbreak commented on Sep 24, 2020

    @Sunbreak
    Contributor

    IIRC, someone were experimenting on merging Platform Runner & UI Runner.

    Would it be another option?

  12. gspencergoog commented on Jan 25, 2021

    @gspencergoog
    ContributorAuthor

    This was fixed by the various delayed key event changes. Closing.

  13. nilsreichardt commented on Feb 19, 2021

    @nilsreichardt
    Contributor

    This can be moved to "Done" in project "Desktop Features", right?

  14. gspencergoog commented on Feb 19, 2021

    @gspencergoog
    ContributorAuthor

    @nilsux Yes, done. Thanks.

  15. siavee commented on Mar 18, 2021

    @siavee

    I have a Wayland Embedder client working with the exception of Keyboard. I send key events, and they're dropped by the engine. It looks like I need to modify the Engine to register a "flutter/keyevent" handler. Will this change enable a default channel in the embedder for keyevents?

    Sorry to bump an old issue, but I'm having the same problem with this comment and I'm not sure where to ask.

    I have successfully embedded Flutter in my OpenGL app using software renderer, using the official 2.0.1 build (using official artifacts from the wiki page. Rendering & mouse/pointer events works fine. However, I'm not able to send or receive any platform messages to/from the flutter engine:

    • The FlutterProjectArgs.platform_message_callback is never called, and
    • sending keyboard events via flutter/keyevent has no effect (I implement something similar to the glfw key handler)

    Also if I use a native plugin, if I invoke MethodChannel from Flutter/Dart side, it never returns.

    For the project args, I only filled assets_path, icu_data_path & platform_message_callback, and the rest I leave to the default values.

    Are there other prerequisites for communication with flutter using platform messages?

    Thanks!

  16. stuartmorgan-g commented on Mar 18, 2021

    @stuartmorgan-g
    Contributor

    @siavee That has nothing to do with this issue. Most likely you aren't servicing the engine tasks (either by providing a platform task runner, or regularly calling the deprecated __FlutterEngineFlushPendingTasksNow).

    If that's not it, you should either file a new issue or use a resource like StackOverlfow or Discord, since this issue was about adding specific new functionality for key events.

  17. siavee commented on Mar 18, 2021

    @siavee

    @stuartmorgan Thanks for the response! That's probably it, I'll try providing a task runner and I'm very sorry about the noise.

  18. github-actions commented on Aug 4, 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.

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: desktopRunning on desktopcustomer: octopodengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions