Add display formats to ItemInput #84
Replies: 2 comments
-
It would be a great addition to the library, I couldn't think of it because of my use case for the library. but first. For the menu item that allows numbers would it not make sense to instead add an upper and lower limit and use a stepper to increase and decrease the value while keeping it in the bounds? |
Beta Was this translation helpful? Give feedback.
-
Hi Thomas, Passing value through two parameters or fixing an upper/lower value would be efficient for our usage, but I wonder how can we pass a decimal position ? Maybe a third parameter ? I had a look at some cobol description tutorials to refresh my mind and it uses also this notation : 9(10) for exemple to pass a 10 numeric position length. "V" chars means the beginning of decimal part description so : 9(10)v99 to get 2 decimal value. Using "Z" char means 'remove non-significative zero' on Cobol but I don't think it will be useful for our usage as display initial value like 0000.00 will help users to understand the expected format value and move the cursor from left to right position. I think Cobol-inspired description could be more evolutive and understandable for users as the format management is stored in just one parameter but you're right about memory usage. I don't know how to appreciate it. in any case, this possible new feature is very attractive :-) |
Beta Was this translation helpful? Give feedback.
-
Hi guys
First of all, you really made a really great work ! Congratulations !
Actually, when running the ItemInput, the variable value is a String type and its length is not limited. It would be useful to add a new optional input format parameter in the ItemInput method (just like Cobol variables descriptions) to control the user input when menu is running.
X means alphanumeric
9 means numeric ( In that case the charset description 0,1,2,3,4,5,6,7,8,9 would be internally managed in the library)
. describe decimal separator char
The cursor position would be managed according to the desired input format and will not exceed the total lenght of the described input.
For example :
"9999" means that input area won't exceed 4 numeric number . Cursor will be allowed to travel across only 4 positions.
"99.9" means that input area is a value from 00.0 to 99.9 In that case, cursor move will jump the "." to go directly to the decimal part of the number and will not exceed 1 decimal position.
"XXXXX" means that input area is an 5 chars long alphanumeric string. Cursor management won't allow to add a sixth char.
User code would be :
MenuItem mainMenu[] = {ItemHeader(),
ItemInput("3-Digits value", "999", "432" , inputCallback), // default value is 432.
ItemInput("2 digits and 1 decimal number", "99.9", "37.7", inputCallback), // default value is 37.7
ItemInput("5 lenght string input", "XXXXX", "HELLO", inputCallback), // default value is HELLO
ItemFooter()};
Hope you'll love the idea ;-)
Beta Was this translation helpful? Give feedback.
All reactions