Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#8776 closed feature (wontfix)

Spinner for numbers

Reported by: xtempore Owned by:
Priority: minor Milestone: 1.10.0
Component: ui.spinner Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


Glad to see a spinner component, but it seems a little underdeveloped at the moment.

I think the most common use for a spinner is to set a numeric value, within a given range. E.g. 1 to 10.

When I use it like this however, it still lets me enter any value, including non-numeric characters.

Seems to me that if it has a min/max that are numeric, it should restrict input to numerics, and prevent numbers out of range being entered.

I know I can add that functionality, but this seems like pretty core stuff to what a spinner widget should do.


Change History (3)

comment:1 Changed 10 years ago by Scott González

Resolution: wontfix
Status: newclosed

Preventing invalid values is actually not core the functionality of a spinner. There are a few possible behaviors for preventing invalid values. Do you mask the input and prevent non-numeric characters? If not, when you blur the field, do you clear it or set it to the min value? Whatever behavior you want can be added fairly easily with all of the existing APIs that spinner provides. Please use the forums or StackOverflow if you need help implementing your desired functionality.

comment:2 Changed 10 years ago by xtempore

"Not core"?

A spinner's primary use is to select a number within a range. There is a "min" and a "max" setting. These clearly show this purpose, and similarly there are values to control stepping - again numeric.

Any reasonable person would therefore assume that the input can only be a value between min and max, and will be numeric.

Saying that "Preventing invalid values is actually not core the functionality of a spinner", is incorrect because it already DOES prevent invalid values in some cases. E.g. when the increase button is clicked, but the max has been reached, it prevents it going to a value higher than max.

So preventing invalid values seems to be core sometimes, but not others. That is an inconsistent, and therefore poor design.

A good test of logical and consistent functionality is how concisely and accurately one can document it.

Which of these looks better...?

min: The minimum allowed value.

min: The minimum allowed value, unless you decide to type something, in which case no checking is applied.

comment:3 Changed 10 years ago by Scott González

When stepping, either via a method or a button, the step is always validated. When entring raw text, the value is never validated.

Again, there are plenty of options for what to do when an invalid value is entered, including trying to parse out a valid value. We do not feel that one implementation should be blessed and implemented. The current implementation allows any desired functionality to be implemented and provides an easy way for making that happen.

Note: See TracTickets for help on using tickets.