From 03d531cd16d923a9807c64033fef76c8dbb3736e Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 29 Mar 2011 20:26:51 +0000 Subject: Fix STR #2588. FLTK was subclassing a very important system-defined class NSApplication. This created conflict with other libraries that do the same. This STR reports that Tcl/Tk is one such library. The fix removes any NSApplication subclass usage in FLTK, and requires to initialize the NSApplication-subclassing library before calling fl_open_display(). In this condition an FLTK application can also use an NSApplication-subclassing library such as Tk. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8546 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 0d8f50878..9b4b4e304 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -632,6 +632,12 @@ static void do_timer(CFRunLoopTimerRef timer, void* data) } @end +@interface FLApplication : NSObject +{ +} ++ (void)sendEvent:(NSEvent *)theEvent; +@end + /* * This function is the central event handler. * It reads events from the event queue using the given maximum time @@ -657,7 +663,7 @@ static double do_queued_events( double time = 0.0 ) inMode:NSDefaultRunLoopMode dequeue:YES]; if (event != nil) { got_events = 1; - [NSApp sendEvent:event]; // reimplemented in [FLApplication sendevent:] + [FLApplication sendEvent:event]; // will then call [NSApplication sendevent:] } fl_lock_function(); @@ -1263,13 +1269,8 @@ extern "C" { } @end -@interface FLApplication : NSApplication -{ -} -- (void)sendEvent:(NSEvent *)theEvent; -@end @implementation FLApplication -- (void)sendEvent:(NSEvent *)theEvent ++ (void)sendEvent:(NSEvent *)theEvent { NSEventType type = [theEvent type]; if (type == NSLeftMouseDown) { @@ -1293,10 +1294,10 @@ extern "C" { // command. This one makes all modifiers consistent by always sending key ups. // FLView treats performKeyEquivalent to keyDown, but performKeyEquivalent is // still needed for the system menu. - [[self keyWindow] sendEvent:theEvent]; + [[NSApp keyWindow] sendEvent:theEvent]; return; } - [super sendEvent:theEvent]; + [NSApp sendEvent:theEvent]; } @end @@ -1307,7 +1308,7 @@ void fl_open_display() { if ( !beenHereDoneThat ) { beenHereDoneThat = 1; - [FLApplication sharedApplication]; + [NSApplication sharedApplication]; NSAutoreleasePool *localPool; localPool = [[NSAutoreleasePool alloc] init]; // never released mydelegate = [[FLDelegate alloc] init]; -- cgit v1.2.3