forked from 1b-agent/opencadstudio-upstream
fix(ui): keep a typed layer or style name when the field loses focus
Renaming a layer or a style was only applied on Enter; clicking anywhere else dropped the typed name. A click that moves focus off a field whose text changed now commits it. New and Copy in the style managers open the generated name for renaming, so a new style can be named right away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4639546472
commit
f6503ad4d3
5 files changed
+93
-46
No files matched your search
+20
-3
@@ -710,7 +710,7 @@ impl OpenCADStudio {
|
||||
// closing the window without Apply calls `style_stage_discard`, which
|
||||
// restores the snapshot taken when the manager opened.
|
||||
|
||||
pub(super) fn style_new(&mut self, kind: StyleKind) {
|
||||
pub(super) fn style_new(&mut self, kind: StyleKind) -> iced::Task<crate::app::Message> {
|
||||
let i = self.active_tab;
|
||||
let name = self.unique_new_name(kind);
|
||||
let h = self.tabs[i].scene.document.allocate_handle();
|
||||
@@ -720,21 +720,37 @@ impl OpenCADStudio {
|
||||
self.after_style_change(kind);
|
||||
self.command_line
|
||||
.push_output(crate::tf!("Style '{name}' created.").as_ref());
|
||||
self.rename_new_style(kind, name)
|
||||
}
|
||||
|
||||
pub(super) fn style_copy(&mut self, kind: StyleKind) {
|
||||
pub(super) fn style_copy(&mut self, kind: StyleKind) -> iced::Task<crate::app::Message> {
|
||||
let i = self.active_tab;
|
||||
let src = self.style_selected(kind);
|
||||
let name = self.unique_suffixed_name(kind, &src);
|
||||
let h = self.tabs[i].scene.document.allocate_handle();
|
||||
if !self.clone_style_as(kind, &src, &name, h) {
|
||||
return;
|
||||
return iced::Task::none();
|
||||
}
|
||||
self.set_style_selected(kind, name.clone());
|
||||
self.load_style_bufs(kind);
|
||||
self.after_style_change(kind);
|
||||
self.command_line
|
||||
.push_output(crate::tf!("Style '{name}' created.").as_ref());
|
||||
self.rename_new_style(kind, name)
|
||||
}
|
||||
|
||||
/// A new style opens with its generated name ready to be typed over.
|
||||
fn rename_new_style(
|
||||
&mut self,
|
||||
kind: StyleKind,
|
||||
name: String,
|
||||
) -> iced::Task<crate::app::Message> {
|
||||
self.style_rename_start(kind, name);
|
||||
let id = crate::ui::style::style_list::rename_input_id();
|
||||
iced::Task::batch([
|
||||
iced::widget::operation::focus(id.clone()),
|
||||
iced::widget::operation::select_all(id),
|
||||
])
|
||||
}
|
||||
|
||||
pub(super) fn style_delete(&mut self, kind: StyleKind) {
|
||||
@@ -770,6 +786,7 @@ impl OpenCADStudio {
|
||||
self.load_style_bufs(kind);
|
||||
self.style_rename_buf = name.clone();
|
||||
self.style_rename = Some(name);
|
||||
self.style_rename_kind = Some(kind);
|
||||
}
|
||||
|
||||
/// Commit the inline rename. No-op (with feedback) on empty / unchanged /
|
||||
|
||||
Reference in new issue
Block a user