diff options
author | Teddy Wing | 2023-08-14 02:19:59 +0200 |
---|---|---|
committer | Teddy Wing | 2023-08-14 02:19:59 +0200 |
commit | b513ebb9b83efda7e59ac0d1257f0ac23f4fe314 (patch) | |
tree | 73956d4690cbf59feba162fc55607dca862e16a8 /src/main_menu.m | |
parent | 5d242798e7a343b2012dca16e8d22af957205f93 (diff) | |
download | Base-Windowed-Application-b513ebb9b83efda7e59ac0d1257f0ac23f4fe314.tar.bz2 |
Move application menu bar code to a new file
Put the menu code in its own file to keep it more organised. We're also
going to be adding a lot more code here for the base main menu.
Wasn't sure if I should be releasing these menu objects, but it looks
like the application works when I do release them, so maybe
`setMainMenu` does a retain or copy.
I can't decide if I should use C-style identifiers or Foundation-style
in the menu file.
Diffstat (limited to 'src/main_menu.m')
-rw-r--r-- | src/main_menu.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main_menu.m b/src/main_menu.m new file mode 100644 index 0000000..6cf11af --- /dev/null +++ b/src/main_menu.m @@ -0,0 +1,22 @@ +#import "main_menu.h" + +NSMenu *main_menu_create() +{ + NSMenu *menubar = [[NSMenu alloc] init]; + NSMenuItem *application_menu_item = [[NSMenuItem alloc] init]; + [menubar addItem:application_menu_item]; + + NSMenu *application_menu = [[NSMenu alloc] init]; + NSMenuItem *quit_menu_item = [[NSMenuItem alloc] + initWithTitle:@"Quit" + action:@selector(terminate:) + keyEquivalent:@"q"]; + [application_menu addItem:quit_menu_item]; + [application_menu_item setSubmenu:application_menu]; + + [quit_menu_item release]; + [application_menu release]; + [application_menu_item release]; + + return menubar; +} |