Quick question: Do the textfields all update to display the last thing you typed into one, or do they all say the same thing (like some initial value) and never change regardless of what you type? If it’s the later, then I think I see what’s happening.
Take a look at the order in which your functions are being called. When we click on the TextField, we call the getKeyboardForInstellenField() function. In here, we set its initial value to the result of getInstellenField(). This function returns the result of the model.get(). However, we have never set this value yet, so it will return the default value, DEFAULT_STARTVERTRAGING.
You can double check this quickly by changing this default value to something else, and seeing if all the textfields now display this new value.
This may be coupling with another issue, which as @nrivas mentions, you are not using UnderRedo manager to wrap your model.set() commands. It should look something like this:
public void onOK(Double value) {
undoRedoManager.recordChanges(() -> {
model.set(INSTELLEN_STARTVERTRAGING, value);
view.setInstellenField(value);
});
}
It’s possible that Polyscope is actually failing to set the model, so you always get the default return value. (Though I thought it threw an error saying it’s failed.)
Another completely different thing you could try is actually passing the contents of the textfield into the callback and use that to set your initial value. So in your view you would have:
KeyboardNumberInput<Double> keyboardInput = provider.get.getKeyboardForInstellenField(instellenField.getText());
You’ll have to add a String parameter to your function in the contribution, and do keyboard.setInitialValue(new_parameter)
This would ensure that what’s displayed when you click the box is always whatever was in the box last. To tie that into openView(), you’d have to use the datamodel with a model.get()
Something like:
view.setinstellenField(model.get(TEXTFIELD_VALUE, DEFAULT_VALUE); //If you have a function in view to access the textfield
Or
view.instellenField.setText(model.get(TEXTFIELD_VALUE, DEFAULT_VALUE)) //If you've declared the textfield as "Public"