Skip to content

Commit

Permalink
Improve HIG compliance of Close and Close All menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Nov 9, 2023
1 parent 73c8fc0 commit 5136d14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions changes/2214.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compliance with Apple's HIG regarding the naming and shortcuts for the Close and Close All menu items was improved.
19 changes: 9 additions & 10 deletions cocoa/src/toga_cocoa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions cocoa/tests_backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"])
Expand Down

0 comments on commit 5136d14

Please sign in to comment.