MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / onButton

Method onButton

src/override/ModuleWidget.cpp:397–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void ModuleWidget::onButton(const ButtonEvent& e) {
398 bool selected = APP->scene->rack->isSelected(this);
399
400 if (selected) {
401 if (e.button == GLFW_MOUSE_BUTTON_RIGHT) {
402 if (e.action == GLFW_PRESS) {
403 // Open selection context menu on right-click
404 ui::Menu* menu = createMenu();
405 patchUtils::appendSelectionContextMenu(menu);
406 }
407 e.consume(this);
408 }
409
410 if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
411 if (e.action == GLFW_PRESS) {
412 // Toggle selection on Shift-click
413 if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
414 APP->scene->rack->select(this, false);
415 e.consume(NULL);
416 return;
417 }
418
419 // If module positions are locked, don't consume left-click
420 if (settings::lockModules) {
421 e.consume(NULL);
422 return;
423 }
424
425 internal->dragOffset = e.pos;
426 }
427
428 e.consume(this);
429 }
430
431 return;
432 }
433
434 // Dispatch event to children
435 Widget::onButton(e);
436 e.stopPropagating();
437 if (e.isConsumed())
438 return;
439
440 if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
441 if (e.action == GLFW_PRESS) {
442 // Toggle selection on Shift-click
443 if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
444 APP->scene->rack->select(this, true);
445 e.consume(NULL);
446 return;
447 }
448
449 // If module positions are locked, don't consume left-click
450 if (settings::lockModules) {
451 e.consume(NULL);
452 return;
453 }
454

Callers

nothing calls this directly

Calls 2

createMenuFunction · 0.85

Tested by

no test coverage detected