MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / keyPressed

Method keyPressed

Source/MainComponent.cpp:465–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463 }
464
465 bool keyPressed(const KeyPress& key) override
466 {
467 /*
468 * This is a temporary fix for 1.0.1. This keyPressed handler
469 * always returns true whether or not Bespoke handles the event
470 * and with juce 6.1.1 it gets all the events. That 'return true'
471 * therefore suppresses the cmd-q/alt-f4 to quit.
472 *
473 * The correct fix is take every key handler and make it have
474 * a return type bool and then at the end return true if any
475 * subordinate key handler returns true, and false if not,
476 * but that touches the entire codebase, so to fix the 1.0 to
477 * 1.0.1. regression with command q on macos, just for now do this
478 * and if it gets merged, open an issue.
479 */
480#if BESPOKE_MAC
481 if (key.getKeyCode() == 'Q' && key.getModifiers().isCommandDown())
482 {
483 return false;
484 }
485#else
486 if (key.getKeyCode() == KeyPress::F4Key && key.getModifiers().isAltDown())
487 {
488 return false;
489 }
490#endif
491
492 int keyCode = key.getTextCharacter();
493 if (keyCode < 32 || key.getModifiers().isAltDown())
494 keyCode = key.getKeyCode();
495 bool isRepeat = true;
496 if (find(mPressedKeys.begin(), mPressedKeys.end(), keyCode) == mPressedKeys.end())
497 {
498 mPressedKeys.push_back(keyCode);
499 isRepeat = false;
500 }
501 mSynth.KeyPressed(keyCode, isRepeat);
502 return true;
503 }
504
505 bool keyStateChanged(bool isKeyDown) override
506 {

Callers

nothing calls this directly

Calls 1

KeyPressedMethod · 0.45

Tested by

no test coverage detected