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

Method KeyPressed

Source/Canvas.cpp:531–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531void Canvas::KeyPressed(int key, bool isRepeat)
532{
533 if (TheSynth->GetLastClickedModule() == GetParent() && gHoveredUIControl == this)
534 {
535 if (key == juce::KeyPress::backspaceKey || key == juce::KeyPress::deleteKey)
536 {
537 if (mControls)
538 mControls->SetElement(nullptr);
539
540 std::vector<CanvasElement*> toRemove;
541 for (auto element : mElements)
542 {
543 if (element->GetHighlighted())
544 toRemove.push_back(element);
545 }
546 for (auto element : toRemove)
547 {
548 RemoveElement(element);
549 }
550 }
551 if (key == 'a' && GetKeyModifiers() & kModifier_Command)
552 {
553 for (auto* element : mElements)
554 element->SetHighlight(true);
555 }
556 if (key == OF_KEY_LEFT || key == OF_KEY_RIGHT)
557 {
558 int direction = (key == OF_KEY_LEFT) ? -1 : 1;
559 for (auto* element : mElements)
560 {
561 if (element->GetHighlighted())
562 element->mCol += direction;
563 }
564 }
565 if (key == OF_KEY_UP || key == OF_KEY_DOWN)
566 {
567 int direction = (key == OF_KEY_UP) ? -1 : 1;
568
569 if (GetKeyModifiers() == kModifier_Shift)
570 direction *= 12; //octave
571
572 for (auto* element : mElements)
573 {
574 if (element->GetHighlighted())
575 element->mRow += direction;
576 }
577 }
578 }
579}
580
581void Canvas::RescaleNumCols(int cols)
582{

Callers 1

keyPressedMethod · 0.45

Calls 5

GetKeyModifiersFunction · 0.85
GetLastClickedModuleMethod · 0.80
SetElementMethod · 0.80
GetHighlightedMethod · 0.80
SetHighlightMethod · 0.80

Tested by

no test coverage detected