mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Fix #392: Cmd+A selects a focused field's text or the type being edited
Select All (Cmd/Ctrl+A) now follows the keyboard, as in Illustrator:
- macOS menu bar: the system menu takes Cmd+A/X/C/V before the window
sees them, so a focused panel, dialog or search field got the document
command. `menus::invoke_from_system_menu` (used by `NativeMenu::poll`)
hands Select All, Cut, Copy and Paste to a focused text field as the
events its keys would send; clicks on those menu items follow the same
rule. Other commands, and these with no field focused, run as before.
- Type tool: `select.all` itself selects all of the text being edited
while the Type tool edits (returns {editing, start, end}), so the menu,
the shortcut, the control channel and headless MCP (`press_key`) agree.
The UI's own Select All interception and the Type tool's hard-wired
Cmd+A are gone; Cmd+A reaches it through the Select All shortcut.
- Windows, Linux and the web already left Cmd+A to a focused field; now
covered by headless app-frame tests (field, Type tool, canvas).
Docs: docs/mcp.md (Select All while editing type), ROADMAP. Not yet:
Select All across threaded frames (one frame's text is selected).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
ffed92aba5
commit
0916534db9
13 files changed
+280
-20
No files matched your search
@@ -61,7 +61,7 @@ impl eframe::App for App {
|
||||
self.menu = Some(native_menu::NativeMenu::install(&mut self.app));
|
||||
}
|
||||
if let Some(m) = &mut self.menu {
|
||||
m.poll(&mut self.app);
|
||||
m.poll(&mut self.app, ctx);
|
||||
}
|
||||
open_files(&mut self.app, open_documents::take());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ pub struct NativeMenu {
|
||||
}
|
||||
|
||||
/// Accelerator for a shortcut like "Cmd+Shift+]" (modifier-less shortcuts stay in the app so they
|
||||
/// don't steal keys from text fields).
|
||||
/// don't steal keys from text fields; a focused field still gets Cmd+A/X/C/V, see [`NativeMenu::poll`]).
|
||||
fn accel(sc: &str) -> Option<Accelerator> {
|
||||
if !(sc.contains("Cmd") || sc.contains("Ctrl") || sc.contains("Alt") || sc.starts_with('F')) {
|
||||
return None;
|
||||
@@ -72,12 +72,13 @@ impl NativeMenu {
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispatch clicked items and refresh state.
|
||||
pub fn poll(&mut self, app: &mut VectorcraftApp) {
|
||||
/// Dispatch chosen items (a focused text field takes Select All and the clipboard) and refresh
|
||||
/// state.
|
||||
pub fn poll(&mut self, app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
while let Ok(ev) = MenuEvent::receiver().try_recv() {
|
||||
if let Some((cmd, params, _, _)) = self.items.get(ev.id.as_ref()) {
|
||||
let p = if params.is_null() { serde_json::json!({}) } else { params.clone() };
|
||||
menus::invoke(app, cmd, p);
|
||||
menus::invoke_from_system_menu(app, ctx, cmd, p);
|
||||
}
|
||||
}
|
||||
let now = vectorcraft_ui_egui::now_ms();
|
||||
|
||||
Reference in new issue
Block a user