mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 16:46:52 +08:00
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
This commit is contained in:
+11
-10
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user