cljfx 2021-10-02

I've got a TextField with a formatter, which is rendered dynamically, and the specific formatter can change. When this happens I seem to get clojure.lang.ExceptionInfo: Replace forbidden {:old-value :long, :new-value :double}. Am I doing something wrong? It's a child in a list so I assume the instance is being reused and it's difficult to atomically set formatter and value all at once (although I'm using the value key inside the text formatter).

Replaces are forbidden in cases where the value is a constructor argument that cannot be changed later, i.e. there is just no way to mutate the object to set the value to a new one

Here are the docs for TextFormatter: https://openjfx.io/javadoc/14/javafx.controls/javafx/scene/control/TextFormatter.html As you can see, it has filter as an argument, but no setters to change it afterwards

The workaround is to re-create the whole text formatter when you want to change its filter

There is an extension lifecycle that does that, described here: https://github.com/cljfx/cljfx/issues/76#issuecomment-645563116

Ah, gotcha, that's nice. Thanks for the pointer!