hi dudes,
trying to intercept GLFW_MOD_CAPS_LOCK
on some widgets:
(e.mods & RACK_MOD_MASK) == GLFW_MOD_CAPS_LOCK
but can’t catch it. what’s the correct way keeping it cross-platform?
thanks, as usual
hi dudes,
trying to intercept GLFW_MOD_CAPS_LOCK
on some widgets:
(e.mods & RACK_MOD_MASK) == GLFW_MOD_CAPS_LOCK
but can’t catch it. what’s the correct way keeping it cross-platform?
thanks, as usual
I don’t really understand the relationship between your requirement and the code fragment you pasted.
You’re asking about caps lock, but you posted code testing for ALT
sorry, was a typo! edited the question
I think you have to determine ModKey like this:
YOUR_MOD_KEY_CODE == (::rack::appGet()->window->getMods() & YOUR_MOD_KEY_CODE)
You must at least obtain the rack app window pointer first, but I’m not sure if I got your problem right.
I see two different things above. The original code sample looks like it is processing a key event and looking for a mod key. the fragment from @qno is trying to determine if they mod key is down “right now”, not modifying a key event. It’s impossible to tell from the original question which they are trying to do.
RACK_MOD_MASK
specifically masks out caps/num/scroll lock. Use
e.mods & GLFW_MOD_CAPS_LOCK
if you want to check if caps lock is enabled when a key is pressed.
works perfectly!
thanks, as usual!
I am struggling to reliabily detect “Alt” key on drag. I’ve tried the methods in this thread, yielding the following MWE
struct AltRoundHugeBlackKnob : RoundHugeBlackKnob {
void onDragStart(const event::DragStart& e) override {
// is alt held at the start of the drag?
int mods = APP->window->getMods();
bool altDrag = (mods & GLFW_MOD_ALT) == GLFW_MOD_ALT;
bool altDrag2 = (mods & GLFW_MOD_ALT);
DEBUG(string::f("onDragStart: %d %d, %d", altDrag, altDrag2, mods).c_str());
RoundHugeBlackKnob::onDragStart(e);
}
};
struct ExampleModuleWidget : ModuleWidget {
ExampleModuleWidget(ExampleModule* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/MyModule.svg")));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addParam(createParam<AltRoundHugeBlackKnob>(mm2px(Vec(5.8586307, 64.250343)), module, ExampleModule::KNOB));
}
};
Every time, I hold ALT then drag the Knob. I get the following in the DEBUG log:
[4.723 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[6.923 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[7.976 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[8.326 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[8.809 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[11.811 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[15.282 info src/patch.cpp:86] Saving patch E:\Documents/Rack/autosave-v1.vcv
[15.284 info src/settings.cpp:189] Saving settings E:\Documents/Rack/settings-v1.json
[15.970 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
[20.392 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
[28.145 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
[30.296 info src/patch.cpp:86] Saving patch E:\Documents/Rack/autosave-v1.vcv
[30.297 info src/settings.cpp:189] Saving settings E:\Documents/Rack/settings-v1.json
[31.767 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
[32.112 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
[34.613 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[34.981 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[35.230 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[35.431 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[35.816 debug src/MyModule.cpp:37] onDragStart: 1 1, 4
[41.991 debug src/MyModule.cpp:37] onDragStart: 0 0, 0
It mainly looks like APP->window->getMods();
isn’t yielding ALT consistently, should I be doing something different? I can’t seem to reproduce it yielding one thing or the other…
Ah nevermind, I think it was because if the window doesn’t have focus (e.g. me looking at log.txt in notepad) when alt is held, then getting VCV focus with a click whilst holding alt doesn’t work (I don’t think i’d expect it to either).
is ALT GR supported by Rack v2? I only see GLFW_MOD_ALT…
BUMP? I see on Rack 2.1.0 you have updated GLFW. Will this also introduce the use of ALT GR?