fix: restore text editing on double click

This commit is contained in:
gianlucafiore 2026-08-13 17:53:24 -03:00
commit 4aa317f413

View file

@ -4206,12 +4206,11 @@ impl OpenCADStudio {
height: vh, height: vh,
}; };
// 1) Try direct wire hit — works when the border is clicked.
let wire_hit: Option<acadrust::Handle> = {
let (view_rot, eye) = { let (view_rot, eye) = {
let c = self.tabs[i].scene.camera.borrow(); let c = self.tabs[i].scene.camera.borrow();
(c.view_proj_rte(bounds), c.eye()) (c.view_proj_rte(bounds), c.eye())
}; };
let all_wires = self.tabs[i].scene.hit_test_wires(); let all_wires = self.tabs[i].scene.hit_test_wires();
let click_world = self.cursor_model_point(i, &edit_cam, p, bounds); let click_world = self.cursor_model_point(i, &edit_cam, p, bounds);
let click_candidates = self.tabs[i].scene.interaction_pick_candidates_near( let click_candidates = self.tabs[i].scene.interaction_pick_candidates_near(
@ -4222,7 +4221,8 @@ impl OpenCADStudio {
bounds, bounds,
crate::ui::overlay::pick_box_aperture_px(self.pick_box) * 2.0, crate::ui::overlay::pick_box_aperture_px(self.pick_box) * 2.0,
); );
scene::pick::hit_test::click_hit(
let raw_wire_hit = scene::pick::hit_test::click_hit(
p, p,
&click_candidates, &click_candidates,
view_rot, view_rot,
@ -4231,8 +4231,38 @@ impl OpenCADStudio {
self.tabs[i].scene.document.header.lineweight_display, self.tabs[i].scene.document.header.lineweight_display,
crate::ui::overlay::pick_box_aperture_px(self.pick_box), crate::ui::overlay::pick_box_aperture_px(self.pick_box),
) )
.and_then(|s| Scene::handle_from_wire_name(s)) .and_then(|s| Scene::handle_from_wire_name(s));
.and_then(|h| {
// In paper space, text editing takes precedence over entering MSPACE.
// This mirrors the model-space double-click behaviour.
if let Some(handle) = raw_wire_hit {
let is_editable_text = self.tabs[i]
.scene
.document
.get_entity(handle)
.is_some_and(|entity| {
crate::app::text_inline::read_text_field(entity).is_some()
|| matches!(entity, AcadEntityType::Leader(_))
});
if is_editable_text {
if let Some(layer) = self.tabs[i].scene.locked_layer_name(handle) {
self.command_line.push_info(
crate::tf!(
"Object is on locked layer \"{layer}\" — unlock the layer to edit it."
)
.as_ref(),
);
return Task::none();
}
return self.begin_text_edit(handle);
}
}
// If the double-click was not on editable text, keep the existing
// paper-space behaviour and try to enter the clicked viewport.
let wire_hit: Option<acadrust::Handle> = raw_wire_hit.and_then(|h| {
if let Some(AcadEntityType::Viewport(vp)) = if let Some(AcadEntityType::Viewport(vp)) =
self.tabs[i].scene.document.get_entity(h) self.tabs[i].scene.document.get_entity(h)
{ {
@ -4244,8 +4274,7 @@ impl OpenCADStudio {
} else { } else {
None None
} }
}) });
};
// 2) Decide which viewport (if any) the click enters, // 2) Decide which viewport (if any) the click enters,
// keyed on the *visible* on-screen rectangle. Screen-space // keyed on the *visible* on-screen rectangle. Screen-space