Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #71119
gspencergoog opened this issue May 29, 2019 · 12 comments
Assignees
Labels
a: desktop Running on desktop customer: octopod engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list

Comments

@gspencergoog
Copy link
Contributor

gspencergoog commented May 29, 2019

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.

@gspencergoog gspencergoog added a: desktop Running on desktop e: desktop labels May 29, 2019
@stuartmorgan-g
Copy link
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.

@stuartmorgan-g stuartmorgan-g added engine flutter/engine repository. See also e: labels. and removed e: desktop labels Jul 26, 2019
@stuartmorgan-g stuartmorgan-g added this to the Goals milestone Aug 13, 2019
@jkurtw
Copy link

jkurtw commented Sep 10, 2019

b/140830852

@jwinarske
Copy link

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?

@stuartmorgan-g
Copy link
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.

@Sunbreak
Copy link
Contributor

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

Would it be another option?

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Jan 25, 2021

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

@nilsreichardt
Copy link
Contributor

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

@gspencergoog
Copy link
Contributor Author

@nilsux Yes, done. Thanks.

@siavee
Copy link

siavee commented Mar 18, 2021

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!

@stuartmorgan-g
Copy link
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.

@siavee
Copy link

siavee commented Mar 18, 2021

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

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop customer: octopod engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list
Projects
None yet
Development

No branches or pull requests