mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 15:21:17 -05:00
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:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user