feat(keyboard): F5/F9/F1 function-key shortcuts and tooltip improvements#1489
feat(keyboard): F5/F9/F1 function-key shortcuts and tooltip improvements#1489J2TeamNNL wants to merge 9 commits into
Conversation
F5 refreshes data (alongside Cmd+R), F9 runs a query (alongside Cmd+Return), and F1 opens documentation. F5 and F9 act as secondary bindings so existing shortcuts are preserved. KeyCombo now recognises F1–F12 via specialKeyName and maps them to the correct NSF_FunctionKey Unicode scalars. A bare function key is allowed without a modifier in both the recorder and sanitization. FunctionKeyShortcutMonitor installs a local NSEvent monitor that dispatches the three function-key actions. It skips events while a ShortcutRecorderNSView holds first-responder so recording still works normally. KeyboardSettings gains a secondary alternates map with its own accessors, conflict detection, and Codable round-trip. ShortcutAction gets a new openDocumentation case (Help category) and supportsFunctionKeyAlternate for Refresh/Execute Query. KeyboardSettingsView shows a second recorder field for actions that support a function-key alternate, and allows function keys without a modifier in both primary and secondary recorders. Tooltips updated: Refresh shows Cmd+R / F5, Inspector toolbar item gains a toolTip, and Columns button in the status bar gets .help(). Docs and CHANGELOG updated; 11 new unit tests cover function-key round-trips, alternates, conflict detection, and sanitization.
There was a problem hiding this comment.
💡 Codex Review
When keyboard settings are loaded, AppSettingsStorage.loadKeyboard() immediately calls sanitized(), but this return value rebuilds KeyboardSettings with only shortcuts and drops alternates. As a result, any customized or cleared F5/F9 alternate binding is lost on app restart or sync import and silently falls back to the defaults; carry the existing sanitized alternates into the returned settings.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| if !combo.hasModifier, !action.allowsBareKey { | ||
| if !combo.hasModifier, !action.allowsBareKey, !combo.isFunctionKey { |
There was a problem hiding this comment.
Reject undispatched primary function-key shortcuts
This allows recording a bare function key as the primary shortcut for any menu-driven action, but keyboardShortcut(for:) then returns nil for function keys and FunctionKeyShortcutMonitor.matchedAction only dispatches the openDocumentation primary plus refresh/executeQuery alternates. For example, assigning F2 as the primary shortcut for Format Query is accepted and displayed in settings, but pressing F2 never reaches the action; limit primary F-key acceptance to actions the monitor actually handles or dispatch all function-key primaries.
Useful? React with 👍 / 👎.
Summary
⌘R / F5, Inspector gets a tooltip, Columns button gets.help()Implementation notes
KeyCombonow recognises F1–F12 (keyCode mapping,NSF_FunctionKeyUnicode scalars, bare key allowed without modifier)FunctionKeyShortcutMonitor(NSEvent local monitor) dispatches F-key actions; skips events whileShortcutRecorderNSViewis first responder so the recorder still worksKeyboardSettingsgains analternatesmap (Codable, conflict detection, accessors).ShortcutActiongetsopenDocumentationcase (Help category) andsupportsFunctionKeyAlternatefor Refresh/Execute QueryKeyboardSettingsViewshows a second recorder for actions with a function-key alternatekeyboardShortcut(for:)returnsnilfor F-key combos so menus don't register them — monitor has sole ownership of function keysTest plan
xcodebuild ... test -only-testing:TableProTests/KeyboardShortcutModelsTests