Skip to content

Handle Command-W to close key window or ruler#162

Merged
pascalpp merged 3 commits into
mainfrom
codex/issue-158-cmd-w-about-window
Jun 7, 2026
Merged

Handle Command-W to close key window or ruler#162
pascalpp merged 3 commits into
mainfrom
codex/issue-158-cmd-w-about-window

Conversation

@pascalpp

@pascalpp pascalpp commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Refactor hiding logic into a new hideRuler(:) helper and replace closePreferences(: ) with closeKeyWindow(_: ). The new action will close the focused ruler (ungrouping if needed) or forward to the key window's performClose. Update validateMenuItem to reflect the new selector and update MainMenu.xib to use closeKeyWindow:. Add a UI test (testRulerCloseWithCommandW) to assert Command-W closes a visible ruler.

Fixes #158

Refactor hiding logic into a new hideRuler(_:) helper and replace closePreferences(_: ) with closeKeyWindow(_: ). The new action will close the focused ruler (ungrouping if needed) or forward to the key window's performClose. Update validateMenuItem to reflect the new selector and update MainMenu.xib to use closeKeyWindow:. Add a UI test (testRulerCloseWithCommandW) to assert Command-W closes a visible ruler.

Fixes #158

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the app’s Cmd-W (“Close”) behavior to close the currently focused ruler window when applicable, otherwise delegating to the active key window’s standard close behavior (fixing Cmd-W not closing non-preferences windows like the About window per #158).

Changes:

  • Refactors ruler-hiding logic into a hideRuler(_:) helper.
  • Replaces the menu action closePreferences(_:) with closeKeyWindow(_:), routing Cmd-W to close the focused ruler or call performClose on the key window.
  • Updates validateMenuItem and MainMenu.xib, and adds a UI test for Cmd-W closing a ruler.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
FreeRulerUITests/FreeRulerUITests.swift Adds a UI test for Cmd-W closing a ruler window.
Free Ruler/Base.lproj/MainMenu.xib Rewires the Close menu item to call closeKeyWindow:.
Free Ruler/AppDelegate.swift Adds hideRuler(_:), implements closeKeyWindow(_:), and updates menu item validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread FreeRulerUITests/FreeRulerUITests.swift
pascalpp and others added 2 commits June 6, 2026 22:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pascalpp pascalpp merged commit 64d0078 into main Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cmd-W should close About window

2 participants