sugarcube-3
sugarcube-3 copied to clipboard
Improvement suggestions for <<numberbox>>
I have some suggestions for improvements to this macro:
- [ ] It considers a decimal point to be an error unless it's .0 -- I think these should be configurable validation settings. Sometimes you want to real numbers, sometimes you only want integers.
- [ ] The text is considered valid if you type in "1." -- This should be considered invalid.
- [ ] It is inconsistent about when it reports errors. If you type "asdf" it reports it as an error when it loses focus. If you type "1.5" it reports it as an error as you are typing. -- this should be consistent, preferably errorring as you type
- [ ] It lets you type in letters, but doesn't save the letters into the variable, preventing you from telling the user that "$var is not a number" (that would print as "0 is not a number") -- I think you should not be allowed to type or paste anything but numbers and decimal points (commas, depending on locale). That would fix a lot of these problems.
- [ ] It would be nice to have way of knowing if the field is invalid. That way, I could prevent a continue button from being clicked. If 0 is a valid number in context, I don't know how to tell if somebody typed in zero or something invalid.
- [ ] It doesn't let you specify a valid range -- I think more often than not, there is a valid range and an invalid range. It would be nice if the macro allowed you to specify it. You should not be able to use numbers outside of this range.
- [ ] It saves a string into the variable, making it inconvenient to implement custom range validation. -- I think the variable should be a number type
- [ ] When you click on the text field, it doesn't highlight the content of the field. This means, if you click and then type 3, it'll probably come out as 30 or 03. You have to click, delete/backspace (depending on which side of the number you clicked), then type what you want to enter -- clicking on the field should highlight the text
- [ ] If you type in letters, clicking the up/down buttons doesn't do anything. I think it should clear the field and +/- the default number. -- ideally, you wouldn't be able to type in letters at all, but if you want to allow that, I think the buttons should clear the field, reset it to the default, and execute the up/down code