Crazy question, Is it possible to change a knob from slide to click (there is button, but testing something)
-
@Yannrog I think it requires a value change which only happens when you slide it, I don't think the callback triggers on click. You might be able to do it with a broadcaster though.
-
@David-Healey Hello @David-Healey
Thank you, It works fine !
So now It has the possibility to slide or click. This is good. Thank you David.
I put a if clicked, value (64)
however, how to add a statement : if clicked again (value 65),
And so on, if click, set 64, if click again, set 65
-
@Yannrog Why not use a button for that?
-
@David-Healey FWIW, it looks a slider does trigger a callback on a slider click (no move):
A plain click with no mouse movement fires the control callback once, on mouse up, with the unchanged value.
- Mouse up (all styles): JUCE ends its drag gesture on every click, which calls
HiSlider::sliderDragEnded. That callssetAttributeWithUndowith the current value, which ends up inProcessorWithScriptingContent::setControlValue.setControlValuecallscontrolCallbackunconditionally, with no "did the value change" check. - Mouse down, Knob style: nothing fires. The rotary drag is relative to the mouse-down position, so the value does not change.
- Mouse down, Horizontal/Vertical with showTextBox off: the value snaps to the click position, so the callback fires on mouse down with the new value, then again on mouse up.
- Mouse down, Horizontal/Vertical with showTextBox on: JUCE skips the snap for a plain click, so only the mouse-up callback fires.
const var Knob1 = Content.addKnob("Knob1", 0, 0); reg count = 0; inline function onControl(component, value) { count++; Console.print(count + ": " + component.getId() + " = " + value); } Knob1.setControlCallback(onControl);Is that what you meant when you said "I don't think the callback triggers on click"?
- Mouse up (all styles): JUCE ends its drag gesture on every click, which calls
-
@Yannrog If you're using clicks on knobs/sliders, be careful of the default 'double-click to reset' action.
-
@David-Healey How to change the default value of a knob, instead of 0, 1?
-
@Yannrog knob or button? If a button you would use a hidden knob to store the value and use the button to increment it. But since it seems like knobs respond to clicks that might be there better way to go after all.
-
@David-Healey Thank you,
The simplest would be a button that as value 64, 65 instead of 0, 1.
The knob is a plus. The button is actually fine
-
@Yannrog A button only has two values. If you don't need the value to be saved in preset then you can use the button to increment a variable. Otherwise you'd need another control to store the value - either a knob or a panel.
If it was me I'd use a panel, but it might be easier for you to use a knob. @dannytaurus Pretty much gave you the code you need above.
-
This post is deleted! -
Thank you @David-Healey @dannytaurus , this is almost there.
However, is it possible to add a statement to this line?
{
if (event.clicked) component.setValue(64);The other statement should be something like
if the value is already set to 64 when clicked again, set to 63.
Is it possible ? or is there another way to do it? Like switching between this 2 values 64 and 63 ?
-
@Yannrog I don't know if I missed some information but, if you only need to switch between 2 different values from a button set it up like this:
inline function onBtnControl(component, value) { local v = value ? 64 : 63; Console.print(v); // control something with v }; Content.getComponent("Btn").setControlCallback(onBtnControl);