mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
OSX keycode character fix.
This commit is contained in:
parent
396a5d9178
commit
4718026b47
2 changed files with 27 additions and 12 deletions
|
|
@ -578,26 +578,42 @@ public:
|
|||
|
||||
bool handleKeyEvent (NSEvent* ev, bool isKeyDown)
|
||||
{
|
||||
String unicode (nsStringToJuce ([ev characters]));
|
||||
String unmodified (nsStringToJuce ([ev charactersIgnoringModifiers]));
|
||||
int keyCode = getKeyCodeFromEvent (ev);
|
||||
const String unicode (nsStringToJuce ([ev characters]));
|
||||
const int keyCode = getKeyCodeFromEvent (ev);
|
||||
|
||||
//DBG ("unicode: " + unicode + " " + String::toHexString ((int) unicode[0]));
|
||||
//String unmodified (nsStringToJuce ([ev charactersIgnoringModifiers]));
|
||||
//DBG ("unmodified: " + unmodified + " " + String::toHexString ((int) unmodified[0]));
|
||||
|
||||
if (unicode.isNotEmpty() || keyCode != 0)
|
||||
if (keyCode != 0 || unicode.isNotEmpty())
|
||||
{
|
||||
if (isKeyDown)
|
||||
{
|
||||
bool used = false;
|
||||
|
||||
while (unicode.length() > 0)
|
||||
for (String::CharPointerType u (unicode.getCharPointer()); ! u.isEmpty();)
|
||||
{
|
||||
juce_wchar textCharacter = unicode[0];
|
||||
unicode = unicode.substring (1);
|
||||
juce_wchar textCharacter = u.getAndAdvance();
|
||||
|
||||
if (([ev modifierFlags] & NSCommandKeyMask) != 0)
|
||||
textCharacter = 0;
|
||||
switch (keyCode)
|
||||
{
|
||||
case NSLeftArrowFunctionKey:
|
||||
case NSRightArrowFunctionKey:
|
||||
case NSUpArrowFunctionKey:
|
||||
case NSDownArrowFunctionKey:
|
||||
case NSPageUpFunctionKey:
|
||||
case NSPageDownFunctionKey:
|
||||
case NSEndFunctionKey:
|
||||
case NSHomeFunctionKey:
|
||||
case NSDeleteFunctionKey:
|
||||
textCharacter = 0;
|
||||
break; // (these all seem to generate unwanted garbage unicode strings)
|
||||
|
||||
default:
|
||||
if (([ev modifierFlags] & NSCommandKeyMask) != 0)
|
||||
textCharacter = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
used = handleKeyUpOrDown (true) || used;
|
||||
used = handleKeyPress (keyCode, textCharacter) || used;
|
||||
|
|
|
|||
|
|
@ -135,8 +135,7 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo)
|
|||
jassert (roundToInt (10.1f) == 10);
|
||||
}
|
||||
|
||||
bool ComponentPeer::handleKeyPress (const int keyCode,
|
||||
const juce_wchar textCharacter)
|
||||
bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textCharacter)
|
||||
{
|
||||
updateCurrentModifiers();
|
||||
|
||||
|
|
@ -186,7 +185,7 @@ bool ComponentPeer::handleKeyPress (const int keyCode,
|
|||
|
||||
if (currentlyFocused != nullptr)
|
||||
{
|
||||
const bool isTab = (keyInfo == KeyPress (KeyPress::tabKey, ModifierKeys::noModifiers, 0));
|
||||
const bool isTab = (keyInfo == KeyPress::tabKey);
|
||||
const bool isShiftTab = (keyInfo == KeyPress (KeyPress::tabKey, ModifierKeys::shiftModifier, 0));
|
||||
|
||||
if (isTab || isShiftTab)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue