summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa/ecore_cocoa.m
diff options
context:
space:
mode:
authorMichelle Legrand <michelle.legrand@openwide.fr>2015-01-22 11:24:42 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 16:38:07 +0100
commit1d18543719a98f9b4e99638c4d8f2e67720b84a2 (patch)
treeb973634a536d61bdac22eca013aeeddbc257edec /src/lib/ecore_cocoa/ecore_cocoa.m
parent8c56edbdf5311295a9ef3254d20d413389756425 (diff)
ecore_cocoa: handle more special characters and capital characters.
This patch is self contained for Mac OS X and improve its keyboard handling. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m68
1 files changed, 43 insertions, 25 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index f02601bb5d..d57fd06482 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -106,6 +106,8 @@ ecore_cocoa_feed_events(void *anEvent)
106 NSEvent *event = anEvent; 106 NSEvent *event = anEvent;
107 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); 107 unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
108 Eina_Bool pass = EINA_FALSE; 108 Eina_Bool pass = EINA_FALSE;
109 static Eina_Bool compose = EINA_FALSE;
110 static NSText *edit;
109 111
110 switch ([event type]) 112 switch ([event type])
111 { 113 {
@@ -243,25 +245,38 @@ ecore_cocoa_feed_events(void *anEvent)
243 Ecore_Event_Key *ev; 245 Ecore_Event_Key *ev;
244 unsigned int i; 246 unsigned int i;
245 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 247 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
248 NSString *keychar = [event characters];
246 249
247 ev = calloc(1, sizeof (Ecore_Event_Key)); 250 ev = calloc(1, sizeof (Ecore_Event_Key));
248 if (!ev) return pass; 251 if (!ev) return pass;
249 ev->timestamp = time; 252 ev->timestamp = time;
250 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); 253 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
251 254
252 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) 255 if (compose)
253 { 256 {
254 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) 257 [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
255 { 258 compose=EINA_FALSE;
256 printf("Key pressed : %s\n", keystable[i].name); 259 }
257 ev->keyname = keystable[i].name; 260
258 ev->key = keystable[i].name; 261 if ([keychar length] > 0){
259 ev->string = keystable[i].compose; 262 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
260 ev->window = (Ecore_Window)window.ecore_window_data; 263 {
261 ev->event_window = ev->window; 264 if (keystable[i].code == [keychar characterAtIndex:0])
262 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); 265 {
263 return pass; 266 printf("Key pressed : %s\n", keystable[i].name);
264 } 267 ev->keyname = keystable[i].name;
268 ev->key = keystable[i].name;
269 ev->string = keystable[i].compose;
270 ev->window = (Ecore_Window)window.ecore_window_data;
271 ev->event_window = ev->window;
272 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
273 return pass;
274 }
275 }
276 }else{
277 compose=EINA_TRUE;
278 edit = [[event window] fieldEditor:YES forObject:nil];
279 [edit interpretKeyEvents:[NSArray arrayWithObject:event]];
265 } 280 }
266 281
267 break; 282 break;
@@ -271,6 +286,7 @@ ecore_cocoa_feed_events(void *anEvent)
271 Ecore_Event_Key *ev; 286 Ecore_Event_Key *ev;
272 unsigned int i; 287 unsigned int i;
273 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 288 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
289 NSString *keychar = [event characters];
274 290
275 printf("Key Up\n"); 291 printf("Key Up\n");
276 292
@@ -279,18 +295,20 @@ ecore_cocoa_feed_events(void *anEvent)
279 ev->timestamp = time; 295 ev->timestamp = time;
280 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]); 296 ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
281 297
282 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i) 298 if ([keychar length] > 0){
283 { 299 for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
284 if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0])) 300 {
285 { 301 if (keystable[i].code == tolower([keychar characterAtIndex:0]))
286 ev->keyname = keystable[i].name; 302 {
287 ev->key = keystable[i].name; 303 ev->keyname = keystable[i].name;
288 ev->string = keystable[i].compose; 304 ev->key = keystable[i].name;
289 ev->window = (Ecore_Window)window.ecore_window_data; 305 ev->string = keystable[i].compose;
290 ev->event_window = ev->window; 306 ev->window = (Ecore_Window)window.ecore_window_data;
291 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); 307 ev->event_window = ev->window;
292 return pass; 308 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
293 } 309 return pass;
310 }
311 }
294 } 312 }
295 313
296 break; 314 break;