From 8bc4d0543db7aecba4655ffa3fdd8574bb83fe2c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 23 Nov 2026 21:52:57 +0700 Subject: [PATCH] The Type tool's editor asks for the keys once, as its edit starts: the framework keeps a focus request made in a press's pass (craft-libs b14f3a313), so it no longer takes them back from its canvas each pass --- crates/ui-egui/src/canvas.rs | 4 ++-- crates/ui-egui/src/type_editing.rs | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 11b1b1f05b..01e6c611ed 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -259,12 +259,12 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O crate::dialogs::dimension::floating(app, ui, space.view.rect); } let editing = app.session.tool_wants_text(); - crate::type_editing::show(app, ui, canvas_id(win)); + crate::type_editing::show(app, ui); out.reply = pass.map(|pass| tool_adapter::run(app, ui, pass)); // An edit the tool host started (a double-click on type) shows its editor in the same pass, so the keys of the // next frame are the edit's. if !editing { - crate::type_editing::show(app, ui, canvas_id(win)); + crate::type_editing::show(app, ui); } } drops::show(app, ui, win, kind); diff --git a/crates/ui-egui/src/type_editing.rs b/crates/ui-egui/src/type_editing.rs index 9ba78a557d..07d622bf3d 100644 --- a/crates/ui-egui/src/type_editing.rs +++ b/crates/ui-egui/src/type_editing.rs @@ -348,8 +348,8 @@ impl Component for TypeEditor<'_> { } /// Shows the editor part over the Type tool's caret while the tool edits text, before the tool host. A new edit target -/// is a new IME owner, so a reloaded document interrupts its composition. `canvas` is the document canvas's id. -pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, canvas: egui::Id) { +/// is a new IME owner, so a reloaded document interrupts its composition. +pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) { if !app.session.tool_wants_text() || app.viewport_hidden(ui.ctx()) { return; } @@ -359,9 +359,8 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, canvas: egui::Id let Some(canvas_view) = app.canvas_view() else { return }; let caret = Rect::from_two_pos(canvas_view.to_screen(a), canvas_view.to_screen(b)).expand2(egui::vec2(1.0, 0.0)); let out = ui.scope_builder(egui::UiBuilder::new().max_rect(caret), |ui| TypeEditor::new(app, caret).id_salt(target).show(ui)).inner; - // Typing goes to the edit that starts, as a click on the part would take the keys. The press that started it - // focuses the canvas as its pass ends, so the editor takes the keys back from its canvas in the next pass. - if out.unfocused_start || focus::has(ui.ctx(), canvas) { + // Typing goes to the edit that starts, as a click on the part would take the keys. + if out.unfocused_start { focus::request(ui.ctx(), FocusTarget::Id(out.response.id)); } }