diff --git a/src/app/update.rs b/src/app/update.rs index bd235a82..b6ec6ca1 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -5103,6 +5103,11 @@ impl OpenCADStudio { if name != "Model" { self.layout_rename_state = Some((name.clone(), name)); self.layout_context_menu = None; + // Focus the inline field so the user types into it + // directly instead of the command line (issue #86). + return iced::widget::operation::focus(iced::widget::Id::new( + crate::ui::statusbar::LAYOUT_RENAME_INPUT_ID, + )); } Task::none() } diff --git a/src/ui/statusbar.rs b/src/ui/statusbar.rs index c757437a..2cb4c163 100644 --- a/src/ui/statusbar.rs +++ b/src/ui/statusbar.rs @@ -4,6 +4,10 @@ use iced::widget::tooltip::Position as TipPos; use iced::widget::{button, container, mouse_area, row, text, text_input, tooltip, Row}; use iced::{Background, Border, Color, Element, Length, Theme}; +/// Widget id of the inline layout-rename text input, so the rename can grab +/// keyboard focus the moment it opens (issue #86). +pub const LAYOUT_RENAME_INPUT_ID: &str = "layout_rename_input"; + use crate::app::Message; use crate::snap::Snapper; use crate::ui::statusbar_config::{StatusBarConfig, StatusPill}; @@ -574,6 +578,7 @@ fn space_tab<'a>( if let Some(edit_val) = rename_edit { // Inline rename text input with a cancel (✕) button. let input = text_input("", edit_val) + .id(iced::widget::Id::new(LAYOUT_RENAME_INPUT_ID)) .on_input(Message::LayoutRenameEdit) .on_submit(Message::LayoutRenameCommit) .size(11)