You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
I've got a text field I want to limit input to numbers. Following the TextFormatter example, I can add a :value-converter :number, but that only takes effect once the field loses focus. Ideally, the user wouldn't even be able to type letters and such into the field.
Here's a solution that shows how to do it with Java and JavaFX. In addition, I want to restrict input to a range (between 20 and 20,000). This is what I came up with to translate that to Clojure and Cljfx:
Since the program continues working and responding (it doesn't crash) and the text field has been successfully limited to entering numbers, I'm happy to ignore the message as just a warning, but the full message is quite long and spams my stdout, so I thought I'd check if I was doing something wrong and if there is something I can do to make the message go away.
Also, using Clojure's Java interop (.getControlNewText %) was the only way I could find to access the state of the TextFormatter. Is there a more idiomatic way to do this with Cljfx (such as a :get-control-new-text key or something)?
The text was updated successfully, but these errors were encountered:
Hi! :filter is a constructor argument of TextFormatter that cannot be modified afterward, that's why it's forbidden to change it — there is no way to apply the change. frequency-field tries to change it because it uses an anonymous function for the filter value, so every call to frequency-field will create a new instance of a filter function. You can fix this by making it a top-level function: