ecore_cocoa: quit application with key
authorThiep Ha <thiepha@gmail.com>
Fri, 23 Sep 2016 08:49:34 +0000 (17:49 +0900)
committerThiep Ha <thiepha@gmail.com>
Fri, 23 Sep 2016 08:49:34 +0000 (17:49 +0900)
In OS X, cmd-q is used to quit application,
this patch adds that feature.

src/lib/ecore_cocoa/ecore_cocoa.m

index ee1188d..2cf1739 100644 (file)
@@ -202,6 +202,18 @@ _ecore_cocoa_feed_events(void *anEvent)
       case NSKeyDown:
         {
            Ecore_Event_Key *ev;
+           NSUInteger flags = [event modifierFlags];
+
+           if (flags & NSCommandKeyMask)
+             {
+                NSString *keychar = [event charactersIgnoringModifiers];
+                if ([keychar characterAtIndex:0] == 'q')
+                  {
+                     [NSApp performSelector:@selector(terminate:)
+                                            withObject:nil afterDelay:0.0];
+                     return EINA_TRUE;
+                  }
+             }
 
            ev = _ecore_cocoa_event_key(event, NSKeyDown, time);
            if (ev == NULL) return EINA_TRUE;