On Thu, Jan 21, 2010 at 6:19 PM, Evan Laforge <[email protected]> wrote:
>> This patch should repair this bug.
>> Please, let me know if it does/doesn't.
>> Thanks for helping debug FLTK-1.3-cocoa
>
> Yes, indeed it does.  Thanks!

I spoke too soon, command+key doesn't send the keyup.  After some
digging around it has to do with some apparently undocumented and
mysterious behaviour wrt NSApplication sending key equivalents.  We
don't need any of that since we already have our own mysterious and
hard to disable key equivalent system (don't get me started on that).
Here's a patch against the current version.  I cut out a bit of unused
code while I was at it:

Index: Fl_cocoa.mm
===================================================================
--- Fl_cocoa.mm (revision 7075)
+++ Fl_cocoa.mm (working copy)
@@ -1391,6 +1391,31 @@
 }
 @end

+...@interface FLApplication : NSApplication
+{
+}
+- (void)sendEvent:(NSEvent *)theEvent;
+...@end
+
+...@implementation FLApplication
+// The default sendEvent swallows key ups when command is down.  This one
+// bypasses all that key equivalent stuff and sends the event directly to the
+// key window.
+//
+// For some reason commancd-esc is still sent as a performKeyEquivalent, so
+// FLView still needs to override performKeyEquivalent to act like keyDown.
+- (void)sendEvent:(NSEvent *)theEvent
+{
+  NSEventType type = [theEvent type];
+  NSWindow *key = [self keyWindow];
+  if (key && (type == NSKeyDown || type == NSKeyUp || type ==
NSFlagsChanged)) {
+    [key sendEvent: theEvent];
+  } else {
+    [super sendEvent:theEvent];
+  }
+}
+...@end
+
 static FLDelegate *mydelegate;

 void fl_open_display() {
@@ -1398,7 +1423,7 @@
   if ( !beenHereDoneThat ) {
     beenHereDoneThat = 1;
        
-    [NSApplication sharedApplication];
+    [FLApplication sharedApplication];
     NSAutoreleasePool *localPool;
     localPool = [[NSAutoreleasePool alloc] init];
     mydelegate = [[FLDelegate alloc] init];
@@ -2012,12 +2037,6 @@
       while (w->parent()) w = w->window(); // todo: this code does
not make any sense! (w!=w??)
     }

-    Rect wRect;
-    wRect.top    = w->y();
-    wRect.left   = w->x();
-    wRect.bottom = w->y() + w->h(); if (wRect.bottom<=wRect.top)
wRect.bottom = wRect.top+1;
-    wRect.right  = w->x() + w->w(); if (wRect.right<=wRect.left)
wRect.right = wRect.left+1;
-
     const char *name = w->label();

     Fl_X* x = new Fl_X;

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

Reply via email to