From 5136d1464c938aa0c493de9c6e2b58838a12020d Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 10 Nov 2023 07:24:05 +0800 Subject: [PATCH] Improve HIG compliance of Close and Close All menu items. --- changes/2214.bugfix.rst | 1 + cocoa/src/toga_cocoa/app.py | 19 +++++++++---------- cocoa/tests_backend/app.py | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 changes/2214.bugfix.rst diff --git a/changes/2214.bugfix.rst b/changes/2214.bugfix.rst new file mode 100644 index 0000000000..97e2873a7e --- /dev/null +++ b/changes/2214.bugfix.rst @@ -0,0 +1 @@ +Compliance with Apple's HIG regarding the naming and shortcuts for the Close and Close All menu items was improved. diff --git a/cocoa/src/toga_cocoa/app.py b/cocoa/src/toga_cocoa/app.py index aec794a051..d22135fdf0 100644 --- a/cocoa/src/toga_cocoa/app.py +++ b/cocoa/src/toga_cocoa/app.py @@ -199,24 +199,23 @@ def _create_app_commands(self): section=sys.maxsize, ), # ---- File menu ---------------------------------- - # This is a bit of an oddity. Safari has 2 distinct "Close Window" and - # "Close All Windows" menu items (partially to differentiate from "Close - # Tab"). Most other Apple HIG apps have a "Close" item that becomes - # "Close All" when you press Option (MOD_2). That behavior isn't something - # we're currently set up to implement, so we live with a separate menu item - # for now. + # This is a bit of an oddity. Apple HIG apps that don't have tabs as + # part of their interface (so, Preview and Numbers, but not Safari) + # have a "Close" item that becomes "Close All" when you press Option + # (MOD_2). That behavior isn't something we're currently set up to + # implement, so we live with a separate menu item for now. toga.Command( self._menu_close_window, - "Close Window", - shortcut=toga.Key.MOD_1 + "W", + "Close", + shortcut=toga.Key.MOD_1 + "w", group=toga.Group.FILE, order=1, section=50, ), toga.Command( self._menu_close_all_windows, - "Close All Windows", - shortcut=toga.Key.MOD_2 + toga.Key.MOD_1 + "W", + "Close All", + shortcut=toga.Key.MOD_2 + toga.Key.MOD_1 + "w", group=toga.Group.FILE, order=2, section=50, diff --git a/cocoa/tests_backend/app.py b/cocoa/tests_backend/app.py index 91f85c0aee..ec9ffaea93 100644 --- a/cocoa/tests_backend/app.py +++ b/cocoa/tests_backend/app.py @@ -117,8 +117,8 @@ def assert_system_menus(self): self.assert_menu_item(["*", "Show All"], enabled=True) self.assert_menu_item(["*", "Quit Toga Testbed"], enabled=True) - self.assert_menu_item(["File", "Close Window"], enabled=True) - self.assert_menu_item(["File", "Close All Windows"], enabled=True) + self.assert_menu_item(["File", "Close"], enabled=True) + self.assert_menu_item(["File", "Close All"], enabled=True) self.assert_menu_item(["Edit", "Undo"], enabled=True) self.assert_menu_item(["Edit", "Redo"], enabled=True) @@ -134,10 +134,10 @@ def assert_system_menus(self): self.assert_menu_item(["Help", "Visit homepage"], enabled=True) def activate_menu_close_window(self): - self._activate_menu_item(["File", "Close Window"]) + self._activate_menu_item(["File", "Close"]) def activate_menu_close_all_windows(self): - self._activate_menu_item(["File", "Close All Windows"]) + self._activate_menu_item(["File", "Close All"]) def activate_menu_minimize(self): self._activate_menu_item(["Window", "Minimize"])