Shortcuts: panel and dialog commands whose params are all optional can be given a key

Edit › Keyboard Shortcuts left out UI commands with no default key, no
menu bar item and a params doc other than {} or {path…}, so New Swatch…,
New Color Group…, Color Group Options…, New Brush…, Brush Options…,
the Layers panel's Options for Selection…, Corners…, Placement Options…,
Relink…, Perspective Plane Options…, Bullets and Numbering…, Missing
Fonts Dialog and Find Fonts in Folder… could not get a key, although
each runs with no params. They are now listed
through a KEY_ONLY_UI list that replaces the `id ==` checks for Rename
and Color Picker…. A key opens the dialog for the selection or the
current item, or the status bar says why it cannot.

Color Group Options… with no group selected now says "select a color
group in the Swatches panel, or pass group" instead of "missing `group`".

Docs: docs/mcp.md, docs/ui-parity.md.
This commit is contained in:
dotCooCoo
2026-11-25 18:44:51 -08:00
parent 016ead2572
commit a868058b44
5 changed files with 61 additions and 6 deletions
@@ -32,7 +32,9 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
let key = "group";
let group = match p.get(key) {
Some(Value::String(g)) => g.clone(),
None | Some(Value::Null) => crate::panels::swatches::sole_selected_group(app).ok_or("missing `group`")?,
None | Some(Value::Null) => {
crate::panels::swatches::sole_selected_group(app).ok_or("select a color group in the Swatches panel, or pass group")?
}
Some(_) => return Err(format!("`{key}` must be a string")),
};
let st = app.session.active().ok_or("no document open")?;
+25 -4
View File
@@ -614,6 +614,29 @@ const NEEDS_A_PARAM: [&str; 77] = [
"type.ruby",
];
/// UI commands with no default key, no menu bar item and a params doc whose fields are all optional
/// that a key press can run with no params: each opens its dialog for the selection, the current
/// item or the panel's selection, or reports in the status bar why it cannot. Rename names the
/// selection, Color Picker… opens for the proxy in front, Brush Options… for the selected path's
/// brush, and Layer Options for the highlighted rows.
pub(crate) const KEY_ONLY_UI: [&str; 15] = [
"ui.rename",
"ui.colorPicker",
"ui.newSwatch",
"ui.newColorGroup",
"ui.colorGroupOptions",
"ui.newBrush",
"ui.brushOptions",
"ui.layerOptions",
"ui.corners",
"ui.placementOptionsDialog",
"ui.relinkDialog",
"ui.perspectivePlane",
"ui.bulletsAndNumbering",
"ui.missingFontsDialog",
"ui.findFontsInFolder",
];
/// The (label, params) of each menu bar item, by command id.
fn menu_bar_items() -> &'static HashMap<String, Vec<(String, Value)>> {
static ITEMS: OnceLock<HashMap<String, Vec<(String, Value)>>> = OnceLock::new();
@@ -704,11 +727,9 @@ fn listed_on_its_own(c: &vectorcraft_engine::CommandSpec) -> bool {
/// Is UI command `id` (default key `sc`, params doc `params`) listed in Edit › Keyboard Shortcuts
/// whether or not an item of the menu bar runs it? It is when it has a default key or a params doc
/// of `{}` or `{path…}`. Rename has no default key, and a key press names the selection: it needs
/// no `id`. Color Picker… has no default key either, and a key press opens it for the proxy in
/// front.
/// of `{}` or `{path…}`, or is one of [`KEY_ONLY_UI`].
fn ui_listed_on_its_own(id: &str, sc: &str, params: &str) -> bool {
!sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || id == "ui.rename" || id == "ui.colorPicker"
!sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || KEY_ONLY_UI.contains(&id)
}
/// Does a menu bar item run the command with no params, so that it does what its label says and opens
+23
View File
@@ -1839,3 +1839,26 @@ fn a_filter_plugin_row_translates_its_path_and_not_its_name() {
assert_eq!(filter, format!("{path} › Group"));
assert_eq!(command, format!("{path} › {}", crate::i18n::tr(zh, "Group")));
}
/// A UI command whose params are all optional and that no item of the menu bar runs can be given a
/// key: Keyboard Shortcuts lists it, and the key opens its dialog or says in the status bar why it
/// cannot.
#[test]
fn a_key_runs_a_ui_command_whose_params_are_all_optional() {
for id in crate::shortcut_editor::KEY_ONLY_UI {
let mut app = app_with_a_selected_rectangle();
let listed = app.run("shortcuts.list", json!({"query": id})).unwrap();
assert!(listed.as_array().is_some_and(|rows| rows.iter().any(|r| r["id"] == id)), "{id} is listed: {listed}");
// Rename edits the name in place and Color Picker… opens the framework's picker; other tests
// check what they open.
if ["ui.rename", "ui.colorPicker"].contains(&id) {
continue;
}
let ctx = ready(&mut app);
bind(&mut app, id, "Cmd+Alt+Shift+F12");
app.ui.status.clear();
key_frame(&mut app, &ctx, tap(Key::F12, cmd() | Modifiers::ALT | Modifiers::SHIFT));
key_frame(&mut app, &ctx, vec![]);
assert!(dialog_kind(&app).is_some() || !app.ui.status.is_empty(), "{id}: the key opens a dialog or reports why not");
}
}
+7
View File
@@ -8167,6 +8167,13 @@ Commands listed this way include `type.fractionalWidths`, `type.systemLayout`, `
`links.embed`, `links.update`, `object.slice.delete`, `artboard.switchOrientation`, `artboard.distributeSpacing`,
`appearance.targetContents` and `paint.invert`.
They also list these UI commands, which have no menu bar item and no default shortcut and whose params are all
optional: `ui.newSwatch`, `ui.newColorGroup`, `ui.colorGroupOptions`, `ui.newBrush`, `ui.brushOptions`,
`ui.layerOptions`, `ui.corners`, `ui.placementOptionsDialog`, `ui.relinkDialog`, `ui.perspectivePlane`,
`ui.bulletsAndNumbering`, `ui.missingFontsDialog` and `ui.findFontsInFolder`. A key assigned to one runs it with no
params, as `{}` does: it opens the dialog for the selection or the current item, or the status bar shows why it cannot,
for example "no brush selected".
Edit › Keyboard Shortcuts and `shortcuts.list` leave out a command with no default shortcut when a key press cannot
run it: no item of the menu bar runs it, it opens no dialog when run without params, and it is one of these:
+3 -1
View File
@@ -416,7 +416,9 @@ the type shortcuts (tracking/kerning/leading/baseline steps with Alt/Shift), and
Layers panel. The shortcut editor also lists the commands that are in no menu but run without parameters (Edit › Duplicate,
panel-menu commands such as Break Link to Symbol), so they can be given shortcuts (#1539). It lists each button of the
Align panel's Align Objects, Distribute Objects and Distribute Spacing rows under Align, with no default shortcut, and a
shortcut set there runs what a click on the button runs, with the panel's Align To choice and Distribute Spacing value. The [ and ] keys reach the Blob Brush, the Eraser and the Symbolism tools in the app (#1734, part of #1661).
shortcut set there runs what a click on the button runs, with the panel's Align To choice and Distribute Spacing value.
It also lists the panel and dialog commands whose parameters are all optional, such as New Swatch…, Brush Options…
and Corners…, and a shortcut set there opens the dialog for the selection or says in the status bar why it cannot. The [ and ] keys reach the Blob Brush, the Eraser and the Symbolism tools in the app (#1734, part of #1661).
Cmd/Ctrl+Alt+. (`stroke.weightUp`, Stroke Weight Up) and Cmd/Ctrl+Alt+, (`stroke.weightDown`, Stroke Weight Down), the keys a [public feature request reply](https://illustrator.uservoice.com/forums/333657-illustrator-desktop-feature-requests/suggestions/32307397-increment-decrement-stroke-weight-key-commands) gives them, step the weight of each selected stroke from its own weight: by a quarter unit of Units › Stroke up to one
unit, then by whole units, down to a quarter unit; with nothing selected they step the weight of the next object drawn (#5797).