0
假設我想在tornadofx中使用appConfig保存視圖的高度和寬度值。無論如何,我可以將這些屬性綁定到appConfig,以便在保存配置時,最新的高度和寬度值將始終保存?有沒有辦法將屬性綁定到tornadofx中的appConfig?
假設我想在tornadofx中使用appConfig保存視圖的高度和寬度值。無論如何,我可以將這些屬性綁定到appConfig,以便在保存配置時,最新的高度和寬度值將始終保存?有沒有辦法將屬性綁定到tornadofx中的appConfig?
如果你想要做的是保存窗口的當前寬度/高度和恢復視圖時再次停靠,您可以覆蓋onDock做這兩個操作有:
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()
}
}
}
}