Anyone know how to make a Spinner with the editabl...
# tornadofx
k
Anyone know how to make a Spinner with the editable property set commit for reasons other than hitting "Enter"? Like if the user tabs out of the control
c
Pinning this...seems like the spinner valueProperty comes up every few months
k
huh, I thought this would be a tornadofx thing
the docs for spinner do say that the Enter key must be pressed
Seems like a design flaw
1
If this method actually works, I wonder if it could be incorporated into the TornadoFX builder...
spinner.focusedProperty().addListener((observable, oldValue, newValue) -> { if (!newValue) { spinner.increment(0); // won't change value, but will commit editor } });
hah, seems to work...
@carlw @Ruckus Would it ever make sense for a list-based spinner to be editable?
I ask because I'm wondering if the focus-based behavior should be omitted from
fun <T> EventTarget.spinner(items: ObservableList<T>, editable: Boolean = false, property: Property<T>? = null, enableScroll: Boolean = false, op: (Spinner<T>.() -> Unit)? = null): Spinner<T>
c
you mean because it's a closed set
k
right
c
maybe add an 11 on-the-fly to a volume control that's only 1-10?
k
I guess validation would catch it
same as if you hit Enter
c
probably a Double is the best use case. there could be a display rounding masking a specific value
r
Maybe if you add some sort of search functionality?
k
I'm thinking of submitting a PR that adds the focus listener (like Sergio's answer in the SO question)
There are several builder functions for Spinner, and I'm just wondering if the listener is not appropriate for the one that is based on a list
Seems appropriate for all the rest
r
I'm not the one to ask about that. I've only ever bothered to use a spinner a handful of times.
k
Seems like numbers are hard to use in a textfield.