Input with Limited Setting

RBM

New member
Joined
Dec 21, 2021
Posts
3
Likes
1
I am trying to create an integer input that is limited to 4 values only.
The input is for a period of an indicator, and the period shall be limited to 34, 21, 13, and 8 only.

This means, that I don't want to have the possibility of selecting periods other than the ones indicated above.
Is this possible ??
Thanks and cheers!
 

TradersCustom

Member
Joined
Sep 8, 2022
Posts
12
Likes
6
In this case, this can't be accomplished with the traditional built-in IntegerDescriptor. You might be able to make a custom IntegerDescriptor class and play around to see how it might be done.

However, since there are only 4 options you want to allow, I'd suggest just using a DiscreteDescriptor so that these 4 periods can be selected from a dropdown. Nothing wrong with this approach. Eg:


Code:
private static final List<NVP> Periods = List.of(

        new NVP("8","8"),
        new NVP("13","13"),
        new NVP("21","21"),
        new NVP("34","34")

);

inputs.addRow(new DiscreteDescriptor(Inputs.PERIOD, "Period", "8", Periods))
 
Top