Author: manolo
Date: 2011-03-29 13:26:51 -0700 (Tue, 29 Mar 2011)
New Revision: 8546
Log:
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.

Modified:
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-03-29 14:22:48 UTC (rev 8545)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-03-29 20:26:51 UTC (rev 8546)
@@ -632,6 +632,12 @@
 }
 @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 @@
                                          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 @@
 }
 @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 @@
     // 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 @@
   if ( !beenHereDoneThat ) {
     beenHereDoneThat = 1;
          
-    [FLApplication sharedApplication];
+    [NSApplication sharedApplication];
     NSAutoreleasePool *localPool;
     localPool = [[NSAutoreleasePool alloc] init]; // never released
     mydelegate = [[FLDelegate alloc] init];

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to