-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement Frame::allow_ime
method
#3313
Conversation
@@ -455,6 +455,9 @@ pub struct NativeOptions { | |||
/// } | |||
/// ``` | |||
pub app_id: Option<String>, | |||
|
|||
/// Enable/disable IME at startup. | |||
pub allow_ime: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please describe this a bit more.
If true
, will an on-screen-keyboard usually be shown for touch-screens on start? Will it hide once the user stops editing text?
If false
, will it still show up when you start editing text? Will it hide once you stop editing the text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
true
, will an on-screen-keyboard usually be shown for touch-screens on start? Will it hide once the user stops editing text?
The keyboard will be shown on startup (Phosh) and you have to manually hide it on.
If
false
, will it still show up when you start editing text? Will it hide once you stop editing the text?
It will not automatically show the keyboard when you enter a text edit. You have to manually show it.
Adding this to my code will automatically show/hide the keyboard on Phosh:
let response = ui.text_edit_singleline(&mut self.text);
if response.gained_focus() {
frame.allow_ime(true);
} else if response.lost_focus() {
frame.allow_ime(false);
}
I added allow_ime
to NativeOptions
in case someone wants to keep the previous behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be that enabling and disabling IME shows and hides the keyboard for other OS/desktops but I really don't have a way to test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me the desirable behavior is to have one flag that controls wether or not the on-screen-keyboard shows on startup (with false
being a reasonable default).
And then, regardless of that flag, always show the on-screen-keyboard when the user clicks a text field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my ultimate goal but egui is rather disconnected from the windowing system, so this was the best that I could come up with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
egui
is disconnected yes, but communicates the necessary information to the backend.
egui-winit
already reads PlatformOutput::text_cursor_pos
to check if the user is editing text
|
Closing in favor of #3362. |
Blindly enabling IME is problematic for Phosh (and probably other Linux desktops that use touch) as it brings up the on-screen keyboard when the app starts. A better solution would be to enable IME when a text edit gains focus and disable IME when it looses focus (which actually shows and hides the on-screen keyboard nicely in Phosh). In order to facilitate this, I have added an
allow_ime
method toFrame
.I also added an
allow_ime
member toNativeOptions
in order to enable IME at startup.