TornadoFX 中有 onCloseWindowEvent() 吗?
Is there an onCloseWindowEvent() in TornadoFX?
我想在控制台中写入一些信息并在我单击 [X] 时显示一个确认对话框(如 "Are You sure to close this window?")。
我知道如何为 Swing 组件做这件事,但我没有找到关于 TornadoFX 的信息(我是 kotlin 的新手)。
是的,您可以为当前 window 配置 onCloseRequest
回调并使用关闭事件。然后你可以提出你自己的问题并在需要时隐藏 window:
override fun onDock() {
currentWindow?.setOnCloseRequest {
it.consume()
confirm("Really close?", "Do you want to close") {
currentWindow?.hide()
}
}
}
我想在控制台中写入一些信息并在我单击 [X] 时显示一个确认对话框(如 "Are You sure to close this window?")。
我知道如何为 Swing 组件做这件事,但我没有找到关于 TornadoFX 的信息(我是 kotlin 的新手)。
是的,您可以为当前 window 配置 onCloseRequest
回调并使用关闭事件。然后你可以提出你自己的问题并在需要时隐藏 window:
override fun onDock() {
currentWindow?.setOnCloseRequest {
it.consume()
confirm("Really close?", "Do you want to close") {
currentWindow?.hide()
}
}
}