ecore_cocoa: quit application with key 32/90432/2
authorThiep Ha <thiepha@gmail.com>
Fri, 23 Sep 2016 08:49:34 +0000 (17:49 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 30 Sep 2016 05:05:05 +0000 (22:05 -0700)
In OS X, cmd-q is used to quit application,
this patch adds that feature.

Change-Id: I898370f4e0c5d518603fc29f3c6e7e72a51d9485

src/lib/ecore_cocoa/ecore_cocoa.m

index 968a802..599daf3 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;