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

Clear compose in TextArea::reset_text #768

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions masonry/src/widget/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ impl<const EDITABLE: bool> TextArea<EDITABLE> {
/// This is likely to be disruptive if the user is focused on this widget,
/// as it does not retain selections, and may cause undesirable interactions with IME.
pub fn reset_text(this: &mut WidgetMut<'_, Self>, new_text: &str) {
// If the IME is currently composing, we need to clear the compose first. This is quite
// disruptive, but we've warned about that. The platform's state is not reset, and the
// preedit will show up again when the platform updates it.
if this.widget.editor.is_composing() {
let (fctx, lctx) = this.ctx.text_contexts();
this.widget
.editor
.transact(fctx, lctx, |txn| txn.clear_compose());
}
this.widget.editor.set_text(new_text);

this.ctx.request_layout();
Expand Down
Loading