mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Adding postCharEvent() to OSX entry.
This commit is contained in:
parent
a96ba40b03
commit
701cd3b3c9
1 changed files with 15 additions and 7 deletions
|
@ -171,20 +171,19 @@ namespace entry
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key::Enum handleKeyEvent(NSEvent* event, uint8_t* specialKeys)
|
Key::Enum handleKeyEvent(NSEvent* event, uint8_t* specialKeys, uint8_t* _pressedChar)
|
||||||
{
|
{
|
||||||
NSString* key = [event charactersIgnoringModifiers];
|
NSString* key = [event charactersIgnoringModifiers];
|
||||||
unichar keyChar = 0;
|
unichar keyChar = 0;
|
||||||
//DBG("keyChar %d", keyChar);
|
|
||||||
if ([key length] == 0)
|
if ([key length] == 0)
|
||||||
{
|
{
|
||||||
return Key::None;
|
return Key::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyChar = [key characterAtIndex:0];
|
keyChar = [key characterAtIndex:0];
|
||||||
|
*_pressedChar = (uint8_t)keyChar;
|
||||||
|
|
||||||
int keyCode = keyChar;
|
int keyCode = keyChar;
|
||||||
//DBG("keyCode %d", keyCode);
|
|
||||||
*specialKeys = translateModifiers([event modifierFlags]);
|
*specialKeys = translateModifiers([event modifierFlags]);
|
||||||
|
|
||||||
// if this is a unhandled key just return None
|
// if this is a unhandled key just return None
|
||||||
|
@ -311,14 +310,20 @@ namespace entry
|
||||||
case NSKeyDown:
|
case NSKeyDown:
|
||||||
{
|
{
|
||||||
uint8_t modifiers = 0;
|
uint8_t modifiers = 0;
|
||||||
Key::Enum key = handleKeyEvent(event, &modifiers);
|
uint8_t pressedChar[4];
|
||||||
|
Key::Enum key = handleKeyEvent(event, &modifiers, &pressedChar[0]);
|
||||||
|
|
||||||
// If KeyCode is none we don't don't handle the key and special case for cmd+q (quit)
|
// If KeyCode is none we don't don't handle the key and special case for cmd+q (quit)
|
||||||
// Note that return false here means that we take care of the key (instead of the default behavior)
|
// Note that return false here means that we take care of the key (instead of the default behavior)
|
||||||
if (key != Key::None)
|
if (key != Key::None)
|
||||||
{
|
{
|
||||||
if (key != Key::KeyQ
|
if ( (Key::Key0 <= key && key <= Key::KeyZ)
|
||||||
&& !(modifiers & Modifier::RightMeta) )
|
|| (Key::Esc <= key && key <= Key::Minus) )
|
||||||
|
{
|
||||||
|
m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
|
||||||
|
}
|
||||||
|
else if (key != Key::KeyQ
|
||||||
|
&& !(modifiers & Modifier::RightMeta) )
|
||||||
{
|
{
|
||||||
m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
|
m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
|
||||||
return false;
|
return false;
|
||||||
|
@ -331,7 +336,10 @@ namespace entry
|
||||||
case NSKeyUp:
|
case NSKeyUp:
|
||||||
{
|
{
|
||||||
uint8_t modifiers = 0;
|
uint8_t modifiers = 0;
|
||||||
Key::Enum key = handleKeyEvent(event, &modifiers);
|
uint8_t pressedChar[4];
|
||||||
|
Key::Enum key = handleKeyEvent(event, &modifiers, &pressedChar[0]);
|
||||||
|
|
||||||
|
BX_UNUSED(pressedChar);
|
||||||
|
|
||||||
if (key != Key::None)
|
if (key != Key::None)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue