fix(annotate): correctly resolve Leader annotations in TEXTEDIT

- Custom recursive resolver ensures Leader entities trace back to their editable Text/MText annotations.

- Bypasses overly strict baseline field checks so TEXTEDIT can natively target and launch the inline editor on Leaders.
This commit is contained in:
Karim Jerbi 2026-06-18 17:49:29 +01:00
commit 8e48bf02a0
2 changed files with 20 additions and 6 deletions

View file

@ -1618,12 +1618,7 @@ impl OpenCADStudio {
return self.begin_text_edit(handle);
}
CmdResult::SuspendForTextEdit { handle } => {
let is_editable = self.tabs[i]
.scene
.document
.get_entity(handle)
.map(|e| crate::app::text_inline::read_text_field(e).is_some())
.unwrap_or(false);
let is_editable = crate::app::text_inline::can_edit_text(handle, &self.tabs[i].scene.document);
if !is_editable {
self.command_line.push_error("TEXTEDIT: selected entity is not text.");
let prompt = self.tabs[i].active_cmd.as_ref().map(|c| c.prompt());

View file

@ -98,6 +98,25 @@ pub struct TextInlineState {
/// Canvas-space anchor where the field is drawn (the insertion-point click).
pub screen_anchor: iced::Point,
}
pub(super) fn can_edit_text(mut handle: Handle, document: &acadrust::CadDocument) -> bool {
for _ in 0..8 {
match document.get_entity(handle) {
Some(acadrust::EntityType::Leader(l)) => {
let ann = l.annotation_handle;
if ann.is_null() || ann == handle {
return false;
}
handle = ann;
}
_ => break,
}
}
if let Some(entity) = document.get_entity(handle) {
read_text_field(entity).is_some()
} else {
false
}
}
impl super::OpenCADStudio {
/// Open the right in-place editor for `handle`: the plain box for single-