forked from 1b-agent/opencadstudio-upstream
fix(grips): cancel value edits before new commands
This commit is contained in:
1 parent
d47e3234d8
commit
a8645c2d95
1 file changed
+39
-5
+39
-5
@@ -75,10 +75,12 @@ impl OpenCADStudio {
|
|||||||
.dispatch_families(cmd, i)
|
.dispatch_families(cmd, i)
|
||||||
.unwrap_or_else(Task::none);
|
.unwrap_or_else(Task::none);
|
||||||
}
|
}
|
||||||
// A new command owns subsequent keyboard input. Any unfinished grip
|
// A new command abandons any grip edit and its numeric input.
|
||||||
// menu value prompt must not survive and intercept that command's
|
let had_pending_grip_input = self.grip_pending.take().is_some();
|
||||||
// coordinates or its final empty Enter.
|
let had_active_grip = self.cancel_active_grip_edit();
|
||||||
self.grip_pending = None;
|
if had_pending_grip_input || had_active_grip {
|
||||||
|
self.command_line.input.clear();
|
||||||
|
}
|
||||||
// Starting a command closes any open ribbon dropdown (e.g. a style
|
// Starting a command closes any open ribbon dropdown (e.g. a style
|
||||||
// combo left open) so it does not stay stuck behind the new tool.
|
// combo left open) so it does not stay stuck behind the new tool.
|
||||||
self.ribbon.close_dropdown();
|
self.ribbon.close_dropdown();
|
||||||
@@ -712,7 +714,10 @@ inventory::submit!(crate::command::CommandRegistration {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod marquee_cancel_tests {
|
mod marquee_cancel_tests {
|
||||||
use crate::app::OpenCADStudio;
|
use crate::app::{GripPendingValue, OpenCADStudio};
|
||||||
|
use crate::scene::model::object::GripMenuAction;
|
||||||
|
use crate::scene::pick::grip::GripEdit;
|
||||||
|
use acadrust::Handle;
|
||||||
use iced::time::Instant;
|
use iced::time::Instant;
|
||||||
|
|
||||||
fn fresh() -> OpenCADStudio {
|
fn fresh() -> OpenCADStudio {
|
||||||
@@ -826,4 +831,33 @@ mod marquee_cancel_tests {
|
|||||||
assert!(sel.box_crossing);
|
assert!(sel.box_crossing);
|
||||||
assert!(sel.box_crossing_locked);
|
assert!(sel.box_crossing_locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn starting_a_command_cancels_a_grip_value_edit() {
|
||||||
|
let mut app = fresh();
|
||||||
|
let i = app.active_tab;
|
||||||
|
let handle = Handle::new(42);
|
||||||
|
app.tabs[i].active_grip = Some(GripEdit::radius(
|
||||||
|
handle,
|
||||||
|
1,
|
||||||
|
glam::DVec3::new(2.0, 0.0, 0.0),
|
||||||
|
));
|
||||||
|
app.grip_pending = Some(GripPendingValue {
|
||||||
|
handle,
|
||||||
|
grip_id: 1,
|
||||||
|
action: GripMenuAction::Radius,
|
||||||
|
label: "New radius",
|
||||||
|
});
|
||||||
|
app.command_line.input = "5".to_string();
|
||||||
|
|
||||||
|
let _ = app.dispatch_command("LINE");
|
||||||
|
|
||||||
|
assert!(app.tabs[i].active_grip.is_none());
|
||||||
|
assert!(app.grip_pending.is_none());
|
||||||
|
assert!(app.command_line.input.is_empty());
|
||||||
|
assert_eq!(
|
||||||
|
app.tabs[i].active_cmd.as_deref().map(|cmd| cmd.name()),
|
||||||
|
Some("LINE")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user