Skip to content

Commit

Permalink
More sensible grid key right-click menu behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewb committed Dec 20, 2021
1 parent 68309eb commit 41c1575
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
33 changes: 31 additions & 2 deletions src/virtualgrid/VirtualGridKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,38 @@ struct VirtualGridKey : rack::app::ParamWidget
endPress();
}
}
else if (e.button == GLFW_MOUSE_BUTTON_RIGHT)
{
// If this key has not been MIDI mapped, the right-click menu
// is not useful, so show the module menu
auto* paramHandle = module
? APP->engine->getParamHandle(module->id, paramId)
: NULL;
if (!paramHandle)
{
return;
}
}

// Repeat logic from ParamWidget::onButton() with minor modifications
OpaqueWidget::onButton(e);

// Record touch so MIDI mapping works
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == 0)
{
if (module)
{
APP->scene->rack->touchedParam = this;
}
e.consume(this);
}

// pass to base class to enable MIDI mapping, right-click menu, etc.
ParamWidget::onButton(e);
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0)
{
destroyTooltip();
createContextMenu();
e.consume(NULL); // replaces e.consume(this), which causes key to get pressed on right click for some reason
}
}

void onDragStart(const rack::event::DragStart& e) override
Expand Down
10 changes: 8 additions & 2 deletions src/virtualgrid/VirtualGridModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ VirtualGridModule::VirtualGridModule(unsigned w, unsigned h)
{
int n = i + j * w * 2;
// first set of params, for midi mapping
configButton(n, rack::string::f("(%d,%d)", i , j));
auto param = configButton(n, rack::string::f("(%d,%d)", i , j));
param->resetEnabled = false;
param->smoothEnabled = false;
param->randomizeEnabled = false;
// second set of params, for interactive use
configButton(n + 1, rack::string::f("(%d,%d)", i, j));
param = configButton(n + 1, rack::string::f("(%d,%d)", i, j));
param->resetEnabled = false;
param->smoothEnabled = false;
param->randomizeEnabled = false;
}
}

Expand Down

0 comments on commit 41c1575

Please sign in to comment.