Added AppDelegate object

This commit is contained in:
Armando Rivera 2023-10-13 12:16:03 -04:00
parent 82ab438219
commit b74b9ff733
2 changed files with 15 additions and 3 deletions

View File

@ -93,13 +93,19 @@
- (BOOL)isFlipped; - (BOOL)isFlipped;
@end @end
@interface CocoaWindow : NSWindow <NSApplicationDelegate,NSUserNotificationCenterDelegate,NSWindowDelegate, NSTextFieldDelegate> @interface AppDelegate : NSObject <NSApplicationDelegate,NSUserNotificationCenterDelegate,NSWindowDelegate, NSTextFieldDelegate>
- (void)applicationDidFinishLaunching: (NSNotification *)notification;
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification;
@end
@interface CocoaWindow : NSWindow
{ {
// NOT USED // NOT USED
} }
- (void)applicationDidFinishLaunching: (NSNotification *)notification;
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification;
- (id) initFormWithTitle:(NSString*)title width:(NSInteger)width height:(NSInteger)height windowStyle: (NSWindowStyleMask) style; - (id) initFormWithTitle:(NSString*)title width:(NSInteger)width height:(NSInteger)height windowStyle: (NSWindowStyleMask) style;
- (void)createApplicationMenu; - (void)createApplicationMenu;
@end @end
@ -622,6 +628,7 @@
id getTab(id parent, const char *name); id getTab(id parent, const char *name);
void eventAction(id widget, EVENT_ACTION callback); void eventAction(id widget, EVENT_ACTION callback);
void setDelegate(id widget);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -119,6 +119,7 @@ void LB_Clear(id widget) {
void Cocoa_Init() { void Cocoa_Init() {
[NSApplication sharedApplication]; [NSApplication sharedApplication];
[NSApp setDelegate: [[AppDelegate new] autorelease]];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
} }
@ -181,3 +182,7 @@ void setSystemAction(id widget, const char *Title, const char *actionName) {
[menuItem setAction: @selector(selector)]; [menuItem setAction: @selector(selector)];
} }
} }
void setDelegate(id widget) {
[NSApp setDelegate: widget];
}