addDefaultKeyPress


#1

Hi, Im trying to install Command-return and Command-? as keyboard shortcuts to a menu. Ive tried on both Linux and Mac but neither of my shortcuts appear in the menu and I cant figure out what I’m doing wrong. Ive tried using both addDefaultKeypress and defaultKeytpresses.add without luck. Ive provided examples of both methods I have been attempting below.

any help appreciated!
best, Rick

// install Command-return as a keyboard shorcut to the menu:

result.addDefaultKeypress( KeyPress::returnKey, ModifierKeys::commandModifier);

result.defaultKeypresses.add( KeyPress::createFromDescription(T(“command + Return”)));

// install Command-? as a keboard shortcut to the menu:

result.addDefaultKeypress(T(’?’), ModifierKeys::commandModifier);

#ifdef MACOSX
result.defaultKeypresses.add( KeyPress::createFromDescription(T(“shift + command + /”)));
#else
result.defaultKeypresses.add( KeyPress::createFromDescription(T(“shift + command + ?”)));
#endif

[/img]


#2

Have you tried doing this to the demo app or the jucer, so you know whether this bit of code is failing, or whether it’s some other aspect of the command handling?


#3

Have you tried doing this to the demo app or the jucer,
I just tried Command-Return in the demo app on osx and does work there. sigh. this is my code in my getCommandInfo and I know its getting executed. So Ill have to poke around some more in my editor’s menu code, thanks!

case cmdLispEval:
result.setInfo (T(“Eval”), String::empty, editingCategory, 0);
result.addDefaultKeypress( KeyPress::returnKey, ModifierKeys::commandModifier);

break;