Skip to content
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

Support IME events abstraction #7315

Closed
liquidhelium opened this issue Jan 21, 2023 · 5 comments
Closed

Support IME events abstraction #7315

liquidhelium opened this issue Jan 21, 2023 · 5 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Enhancement A new feature

Comments

@liquidhelium
Copy link

What problem does this solve or what need does it fill?

To be honest, not having input method support can be seen as a bug, which even makes me discouraged from bevy. Whether it is a GUI integration made by someone else (such as bevy_egui) or a GUI system made by ourselves, sooner or later it will have to deal with the problem of input methods. For users like us, GUI systems without input method support are not usable, so I hope we can take a small step in this regard by providing the ability to handle IME events with an abstract API.

What solution would you like?

The definition of these events should probably be put in bevy_window/events.rs, and then we convert these events in the backend. For winit, the definition of these events can be found at winit::event::ime. Notice that we need to add methods that provide access to window.set_ime_position.

What alternative(s) have you considered?

I guess you can only enter CJK characters by copy-pasting. I have to say it's very bad UX.

Additional context

Here is a pull request that adds IME support to egui_winit: emilk/egui#2046

and a solution for web: emilk/egui#253

@liquidhelium liquidhelium added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Jan 21, 2023
@liquidhelium
Copy link
Author

I would appreciate it if someone could respond quickly, as the issue I created in some other repositories went unanswered.

@minecrawler
Copy link

related to #6213

I'm not sure if IME should be handled in the window/events, since you'll only want to do IME in a text input - correct me if I'm wrong, but I never used it any other way...

So I'd rather see a solid base text input component, which gets re-used in other widgets. Shouldn't that be also part of the endeavour of writing the editor (dogfeeding solid, usable UI components)?

On the other hand, handling IME on a lower level (window/events) would allow other UI implementations to also write custom IME support easily. How likely is that once Bevy offers a solid solution?

@liquidhelium
Copy link
Author

In fact I was trying bevy_egui but found it has no IME support. I tried to add this functionality to it, and then found that there is no API to handle these events.

@minecrawler
Copy link

I would appreciate it if someone could respond quickly, as the issue I created in some other repositories went unanswered.

If you want to have a quick discussion, btw, you might find that easier on the Discord!

@mockersf
Copy link
Member

mockersf commented Jan 21, 2023

I have no knowledge of how IME works, but it looks like it needs to be enabled on winit with Window::set_ime_allowed()

To get winit window:

that should give you the winit windows where you can enable IME. This is what would be currently needed, but it would make sense to improve that scenario with a quick PR that would do all that for you in a simple function.

Once that's down, I suppose you should expect WindowEvent::Ime events from winit. Those are probably ignored for now, but adding their support should be a very easy PR.

@mockersf mockersf added A-Input Player input via keyboard, mouse, gamepad, and more and removed S-Needs-Triage This issue needs to be labelled labels Jan 21, 2023
@bors bors bot closed this as completed in 3999365 Jan 29, 2023
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fix bevyengine#7315
- Add IME support

## Solution

- Add two new fields to `Window`, to control if IME is enabled and the candidate box position

This allows the use of dead keys which are needed in French, or the full IME experience to type using Pinyin

I also added a basic general text input example that can handle IME input.

https://user-images.githubusercontent.com/8672791/213941353-5ed73a73-5dd1-4e66-a7d6-a69b49694c52.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Enhancement A new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants