From a3bbb5f9d397d1d296578eb7702869327070de4d Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 21 May 2021 15:29:55 +0300 Subject: [PATCH] cocoa: add standard app menu items Added "Hide ", "Hide Others" and "Show All" in a separate section immediately preceding "Quit". Also added Cmd+, as a shortcut for "Preferences" and sectioned it off. Closes #1261. Signed-off-by: layday --- src/cocoa/toga_cocoa/app.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/cocoa/toga_cocoa/app.py b/src/cocoa/toga_cocoa/app.py index b3e162fd00..647a393bae 100644 --- a/src/cocoa/toga_cocoa/app.py +++ b/src/cocoa/toga_cocoa/app.py @@ -131,8 +131,37 @@ def create(self): 'About ' + formal_name, group=toga.Group.APP ), - toga.Command(None, 'Preferences', group=toga.Group.APP), - # Quit should always be the last item, in a section on it's own + toga.Command( + None, + 'Preferences', + shortcut=toga.Key.MOD_1 + ',', + group=toga.Group.APP, + section=20, + ), + toga.Command( + lambda _: self.native.hide(self.native), + 'Hide ' + formal_name, + shortcut=toga.Key.MOD_1 + 'h', + group=toga.Group.APP, + order=0, + section=sys.maxsize - 1, + ), + toga.Command( + lambda _: self.native.hideOtherApplications(self.native), + 'Hide Others', + shortcut=toga.Key.MOD_1 + toga.Key.MOD_2 + 'h', + group=toga.Group.APP, + order=1, + section=sys.maxsize - 1, + ), + toga.Command( + lambda _: self.native.unhideAllApplications(self.native), + 'Show All', + group=toga.Group.APP, + order=2, + section=sys.maxsize - 1, + ), + # Quit should always be the last item, in a section on its own toga.Command( lambda _: self.interface.exit(), 'Quit ' + formal_name,