cleaner OS X character handling

This commit is contained in:
Jack Andersen 2015-12-27 14:23:15 -10:00
parent 30fd4c0709
commit e21074ce57
1 changed files with 16 additions and 6 deletions

View File

@ -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];
}