min max value next prev btn
-
inline function onnextControl(component, value) { viewport.setValue((viewport.getValue() + 1)); viewport.changed(); }; Content.getComponent("next").setControlCallback(onnextControl);
hello, I am trying to make a next/prev button from my preset list in a viewport. it works but if I press prev once the first preset in my list is selected my viewport continues to scroll in vain. as if there was no min and max value. I don't know if you understand. To put it simply, I would simply like to navigate from the first to the last preset without it going over. if I have 10 presets I want to be able to navigate between my 10 presets and not -1 preset -2 preset 11, 12 13 preset. :) what is missing from my line? I tried getmaxValue but to no avail
-
You need to check if the new value will exceed the min/max before you apply it.
inline function onnextControl(component, value) { if (viewport.getValue() + 1 > viewport.get("max")) return; viewport.setValue((viewport.getValue() + 1)); viewport.changed(); };
-
Actually I just realised the viewport doesn't have a
max
property so you'll need to decide what you max is some other way. But apart from that the principle is the same. -
@d-healey and yes that is the problem. so I should probably know how many presets I have. imagine 150 I must put max=150?
-
@yall Or you could use
Engine.getUserPresetList().length
to find out the actual number. -
if (value) { viewport.setValue( viewport.getValue() == 0 ? list.length-1 : viewport.getValue() - 1); viewport.changed(); }
it's ok ;) thank u