Cursors: a Caps Lock command before the first frame stays in place

The first host Caps Lock reading is now only a baseline when view.capsLock already set the session state, so the command no longer resets on the first canvas pass.
This commit is contained in:
dotCooCoo committed 2026-11-25 23:10:55 -08:00
1 parent fb68251203
commit 1fed7a4e6f
2 files changed
+21

No files matched your search

+5
View File
@@ -423,7 +423,12 @@ impl VectorcraftApp {
if self.canvas.host_caps_lock == Some(on) {
return;
}
let first_reading = self.canvas.host_caps_lock.is_none();
self.canvas.host_caps_lock = Some(on);
// A `view.capsLock` call that ran before the first reading stays in place; that reading is only the baseline.
if first_reading && self.session.caps_lock {
return;
}
if self.session.caps_lock != on
&& let Err(err) = self.run("view.capsLock", serde_json::json!({ "on": on }))
{
@@ -136,3 +136,19 @@ fn the_caps_lock_command_gives_the_brushes_the_crosshair() {
assert!(shows_tip(&mut app));
assert_ne!(craft::ui::runtime::cursor::current(&ctx), crosshair);
}
/// A `view.capsLock` call that runs before the first canvas pass stays in place when the host's Caps Lock is off.
#[test]
fn the_caps_lock_command_before_the_first_frame_stays_in_place() {
use craft::ui::runtime::windows::WindowHost;
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", serde_json::json!({"width": 400, "height": 300})).unwrap();
app.select_tool("blobBrush");
app.run("view.capsLock", serde_json::json!({"on": true})).unwrap();
let ctx = crate::testing::ui_context();
WindowHost::of(&ctx).set_caps_lock(Some(false));
frame(&mut app, &ctx, vec![]);
assert!(app.session.caps_lock, "the first host reading is only the baseline");
frame(&mut app, &ctx, vec![]);
assert!(app.session.caps_lock);
}