From e21074ce57197fceadc42f0b12e1cce98112a1d2 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 27 Dec 2015 14:23:15 -1000 Subject: [PATCH] cleaner OS X character handling --- lib/mac/WindowCocoa.mm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/mac/WindowCocoa.mm b/lib/mac/WindowCocoa.mm index 2784ace..49b9538 100644 --- a/lib/mac/WindowCocoa.mm +++ b/lib/mac/WindowCocoa.mm @@ -978,14 +978,19 @@ static boo::ESpecialKey translateKeycode(short code) if (!booContext->m_callback) return; boo::ESpecialKey special = translateKeycode(theEvent.keyCode); - NSString* chars = theEvent.characters; + boo::EModifierKey mods = getMod(theEvent.modifierFlags); + NSString* chars; + if ((mods & boo::EModifierKey::Ctrl) != boo::EModifierKey::None) + chars = theEvent.charactersIgnoringModifiers; + else + chars = theEvent.characters; if (special != boo::ESpecialKey::None) booContext->m_callback->specialKeyDown(special, - getMod(theEvent.modifierFlags), + mods, theEvent.isARepeat); else if ([chars length]) booContext->m_callback->charKeyDown([chars characterAtIndex:0], - getMod(theEvent.modifierFlags), + mods, theEvent.isARepeat); [textContext handleEvent:theEvent]; } @@ -995,13 +1000,18 @@ static boo::ESpecialKey translateKeycode(short code) if (!booContext->m_callback) return; boo::ESpecialKey special = translateKeycode(theEvent.keyCode); - NSString* chars = theEvent.characters; + boo::EModifierKey mods = getMod(theEvent.modifierFlags); + NSString* chars; + if ((mods & boo::EModifierKey::Ctrl) != boo::EModifierKey::None) + chars = theEvent.charactersIgnoringModifiers; + else + chars = theEvent.characters; if (special != boo::ESpecialKey::None) booContext->m_callback->specialKeyUp(special, - getMod(theEvent.modifierFlags)); + mods); else if ([chars length]) booContext->m_callback->charKeyUp([chars characterAtIndex:0], - getMod(theEvent.modifierFlags)); + mods); //[textContext handleEvent:theEvent]; }