VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Handle Shift Alt arrows on selected type
Mirko Kerezovica79bf0f42e9a
diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rsindex c041cd54e..7493f362e 100644--- a/crates/ui-egui/src/shortcuts.rs+++ b/crates/ui-egui/src/shortcuts.rs@@ -646,11 +646,11 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {(Key::ArrowDown, Some((if m.shift { "baselineShift" } else { "leading" }, if m.shift { -1.0 } else { 1.0 }))),];for (key, step) in steps {- if let Some((attribute, by)) = step- && ctx.input_mut(|i| i.consume_key(m, key))- {- let by = if m.command { by * 5.0 } else { by };- let _ = app.run("type.step", json!({"attribute": attribute, "by": by}));+ if ctx.input_mut(|i| i.consume_key(m, key)) {+ if let Some((attribute, by)) = step {+ let by = if m.command { by * 5.0 } else { by };+ let _ = app.run("type.step", json!({"attribute": attribute, "by": by}));+ }return;}}@@ -1676,6 +1676,13 @@ mod tests {let r = app.session.execute("text.getRange", &json!({"id": id})).unwrap();assert_eq!(r["runs"][0]["style"]["baseline_shift"], json!(2.0));+ // Shift+Alt+Left/Right have no text-spacing action; they must still be consumed instead of+ // falling through to Alt+arrow's copy-and-nudge behaviour.+ for key in [Key::ArrowLeft, Key::ArrowRight] {+ frame(&mut app, vec![egui::Event::ModifiersChanged(alt_shift), press(key, alt_shift)]);+ assert_eq!(app.session.active().unwrap().selection.objects, [vectorcraft_doc::NodeId(id)]);+ }+// Other objects keep Alt+arrow's copy-and-nudge shortcut.let rect = app.session.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();app.session.execute("select.set", &json!({"ids": [rect]})).unwrap();