Can't use comma and period with ApplicationCommandInfo::want


#1

If I try and use the shortcut keys comma or period with ApplicationCommandInfo::wantsKeyUpDownCallbacks it doesn’t work. If I remove that flag, it works.

I can use other keys with the flag, like the arrow keys or letters or numbers.

Any ideas?


#2

hmm - if you use the up/down callback, it has to use a different mechanism that doesn’t translate keypresses as characters, so it could be that the key-state checker isn’t working for those keys. Is this on mac or windows?


#3

windows


#4

Ok, seems like a few keycodes need some special treatment - try this bodge in juce_Windowing.cpp:

[code]bool KeyPress::isKeyCurrentlyDown (int keyCode)
{
SHORT k = keyCode & 0xffff;

if ((keyCode & nonAsciiKeyFlag) == 0
     && (k >= T('a') && k <= T('z')))
    k += T('A') - T('a');

const SHORT translatedValues[] = { (SHORT) ',', VK_OEM_COMMA,
                                   (SHORT) '+', VK_OEM_PLUS,
                                   (SHORT) '-', VK_OEM_MINUS,
                                   (SHORT) '.', VK_OEM_PERIOD,
                                   (SHORT) '/', VK_OEM_2,
                                   (SHORT) '?', VK_OEM_2,
                                   (SHORT) '[', VK_OEM_4,
                                   (SHORT) ']', VK_OEM_6 };

for (unsigned int i = 0; i < sizeof (translatedValues) / sizeof (translatedValues[0]); i += 2)
    if (k == translatedValues [i])
        k = translatedValues [i + 1];

return (GetKeyState (k) & 0x8000) != 0;

}
[/code]


#5

fixed. thanks. :smiley:


#6

shift+arrow and ctrl+shift+arrow also don’t work with ApplicationCommandInfo::wantsKeyUpDownCallbacks


#7

Ok, try this as a fix…

[code]bool KeyPress::isCurrentlyDown() const
{
int modsMask = ModifierKeys::commandModifier | ModifierKeys::ctrlModifier | ModifierKeys::altModifier;

if (keyCode == KeyPress::downKey 
    || keyCode == KeyPress::upKey
    || keyCode == KeyPress::leftKey
    || keyCode == KeyPress::rightKey
    || keyCode == KeyPress::deleteKey
    || keyCode == KeyPress::backspaceKey
    || keyCode == KeyPress::returnKey
    || keyCode == KeyPress::escapeKey
    || keyCode == KeyPress::homeKey
    || keyCode == KeyPress::endKey
    || keyCode == KeyPress::pageUpKey
    || keyCode == KeyPress::pageDownKey
    || (keyCode >= KeyPress::F1Key && keyCode <= KeyPress::F12Key))
{
    modsMask |= ModifierKeys::shiftModifier;
}

return isKeyCurrentlyDown (keyCode)
        && (ModifierKeys::getCurrentModifiers().getRawFlags() & modsMask)
              == (mods.getRawFlags() & modsMask);

}[/code]


#8

fixed it, thanks


#9