-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add PlainEditor
method to get IME cursor area
#224
Conversation
The area reported is the area of text the user is currently editing. It is usually used by platforms to place a candidate box for IME near it, while ensuring it is not obscured. The implementation here ensures the area is usually near the focus, that the area contains at least some surrounding context (in case the platform places something to the side of the area, instead of above or under), and that the IME candidate box usually does not need to jump around when the IME starts or continues composing.
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.
Looks good. I've not tested it
examples/vello_editor/src/main.rs
Outdated
@@ -340,6 +358,7 @@ fn main() -> Result<()> { | |||
scene: Scene::new(), | |||
editor: text::Editor::new(text::LOREM), | |||
last_drawn_generation: Default::default(), | |||
last_sent_ime_cursor_area: None, |
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.
Maybe this should be an arbitrary definitely invalid rect? E.g. 0x0 at (0, 0)
or similar
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's now flattened and splatted with NaN, which should definitely never be returned.
// until https://github.com/rust-windowing/winit/pull/3966 is in the Winit release | ||
// used by this example. | ||
render_state.window.set_ime_cursor_area( | ||
PhysicalPosition::new( |
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.
Hmm, is physical right here?
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 think it is, but I haven't tested it with a non-1
display scale. The editor gets its width set as the physical width in
parley/examples/vello_editor/src/main.rs
Lines 228 to 235 in 85a824a
WindowEvent::Resized(size) => { | |
self.context | |
.resize_surface(&mut render_state.surface, size.width, size.height); | |
let editor = self.editor.editor(); | |
editor.set_scale(1.0); | |
editor.set_width(Some(size.width as f32 - 2f32 * text::INSET)); | |
render_state.window.request_redraw(); | |
} |
The area reported is the area of text the user is currently editing. It is usually used by platforms to place a candidate box for IME near it, while ensuring it is not obscured.
The implementation here ensures the area is usually near the focus, that the area contains at least some surrounding context (in case the platform places something to the side of the area, instead of above or under), and that the IME candidate box usually does not need to jump around when the IME starts or continues composing.