Suppose I want to save a view's height and width value using appConfig in tornadofx. Is there anyway I can bind these properties to appConfig, so that when I save the config, the latest value of height and width will always be saved?
If what you want to do is to save the current width/height of the Window and restore that when the View is docked again, you can override onDock to do both operations there:
override fun onDock() {
if (config["w"] != null && config["h"] != null) {
currentWindow?.apply {
width = config.double("w")!!
height = config.double("h")!!
}
}
currentWindow?.apply {
Bindings.add(widthProperty(), heightProperty()).onChange {
with (config) {
put("w", width.toString())
put("h", height.toString())
save()
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.