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

This commit is contained in:
bflatastic
2026-11-23 21:52:57 +07:00
parent b2fb4f9101
commit 8bc4d0543d
2 changed files with 6 additions and 7 deletions
+2 -2
View File
@@ -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);
+4 -5
View File
@@ -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));
}
}