@ron Fixed "wether", made the intro list parallel, some commas added for the longer clause, removed an extra "Now" that was repeated in the final code example lead-in
Any kind of user oriented application, whether a web application, a mobile application or a desktop application, interacts with the user. That interaction is usually some kind of "fill in these fields please, so something can happen".
KeepassFX has several such interactions. And of course they are implemented with tornadoFX builders. The nice thing about developing keepassFX while constantly talking with in the Slack tornadoFX channel means that usecases I encounter will very often result in updates in the builders.
textfield(username).required() has the validator required(). Validators can only be used on properties that are part of a ViewModel(). Because of the validators, the code for the OK button can contain the model.commit function. This ensures that the code inside the model.commit block will only be executed when all the validators are happy. If you press OK button and the validators will decorate the fields that do not pass validation:
Since this afternoon, there is another way of doing this. button has the function enableWhen and disableWhen. Now you can link this to the validation state.
Now the OK button will only be enabled if all the validators are happy. The code looks like this: