slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.93k stars 565 forks source link

Support chinese IME for text input widget. #1644

Closed AllenDang closed 1 year ago

AllenDang commented 2 years ago

I'm using macOS M1 and I found out that text input widget doesn't support to input chinese from IME.

Is it possible to support it? Otherwise I cannot input any chinese into it.

It's not a issue about how to display chinese characters, but how to support IME in macOS.

hunger commented 2 years ago

Which style did you use?

I would recommend you try with the native style which uses Qt in the back. That is the best option for integration with OS services at this time. Doing this without Qt will take us some time still -- there are just a lot of integration points (and a few OSes;-) to implement support for!

Try setting SLINT_STYLE=native in your environment while running cargo should get you a build using Qt in the backend. Of course that also requires Qt to be installed on your machine.

AllenDang commented 2 years ago

@hunger Thanks to reply. I understand the integration is hard and heavy, but involve Qt will make the deployment kind of hard, I will wait for the integration. :P

hunger commented 2 years ago

Feel free to chip in: We are a bit understaffed in the Mac department ;-)

ogoffart commented 2 years ago

When not using the Qt backend, we are using winit which should already support IME. (Some bugs for it were reported before: #511 ). So I believe it should work.

AllenDang commented 2 years ago

@ogoffart I specified winit as backend and the IME still doesn't work.

As you can see below, IME is on, and when I type anything in to line edit, IME is not working.

截屏2022-09-16 10 39 48

tronical commented 2 years ago

Yeah unfortunately we don’t respond to IME events and queries right now, apart from Oliver’s recent fix for IME commits.

Both winit and Qt have APIs that should make it possible (like set_ime_position) and thankfully both connect with macOS and Windows APIs.

In Qt this is also used to implement virtual keyboards. We could use the same approach if we make the interface part of slint::Window.

tronical commented 1 year ago

This is fixed by https://github.com/slint-ui/slint/pull/1728