MCPcopy Create free account
hub / github.com/VCVRack/Rack / onButton

Method onButton

src/app/ModuleWidget.cpp:374–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374void ModuleWidget::onButton(const ButtonEvent& e) {
375 bool selected = APP->scene->rack->isSelected(this);
376
377 if (selected) {
378 if (e.button == GLFW_MOUSE_BUTTON_RIGHT) {
379 if (e.action == GLFW_PRESS) {
380 // Open selection context menu on right-click
381 ui::Menu* menu = createMenu();
382 APP->scene->rack->appendSelectionContextMenu(menu);
383 }
384 e.consume(this);
385 }
386
387 if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
388 if (e.action == GLFW_PRESS) {
389 // Toggle selection on Shift-click
390 if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
391 APP->scene->rack->select(this, false);
392 e.consume(NULL);
393 return;
394 }
395
396 // If module positions are locked, don't consume left-click
397 if (settings::lockModules) {
398 e.consume(NULL);
399 return;
400 }
401
402 internal->dragOffset = e.pos;
403 }
404
405 e.consume(this);
406 }
407
408 return;
409 }
410
411 // Dispatch event to children
412 Widget::onButton(e);
413 e.stopPropagating();
414 if (e.isConsumed())
415 return;
416
417 if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
418 if (e.action == GLFW_PRESS) {
419 // Toggle selection on Shift-click
420 if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
421 APP->scene->rack->select(this, true);
422 e.consume(NULL);
423 return;
424 }
425
426 // If module positions are locked, don't consume left-click
427 if (settings::lockModules) {
428 e.consume(NULL);
429 return;
430 }
431

Callers

nothing calls this directly

Calls 7

createMenuFunction · 0.85
isSelectedMethod · 0.80
consumeMethod · 0.80
selectMethod · 0.80
stopPropagatingMethod · 0.80
isConsumedMethod · 0.80

Tested by

no test coverage detected