如何防止表单隐藏 TornadoFX
How to prevent form hiding TornadoFX
我需要通过按 alt + f4 禁用关闭我的应用程序(它在全屏模式下运行)。我阅读了其他线程并编写了以下代码:
override fun start(stage: Stage) {
Platform.setImplicitExit(false)
stage.addEventFilter(KeyEvent.KEY_PRESSED) {
if (it.isAltDown && it.code == KeyCode.F4) {
it.consume()
}
}
stage.setOnHiding { _ -> EventHandler<WindowEvent> { it.consume() } }
stage.setOnCloseRequest { _ -> EventHandler<WindowEvent> {
it.consume()
} }
stage.fullScreenExitKeyCombination = KeyCombination.NO_MATCH
stage.fullScreenExitHint = ""
stage.isFullScreen = true
super.start(stage)
}
问题是我的应用程序没有关闭,但阶段被隐藏了。如何通过按 alf+f4 使表单不被隐藏?
我尝试将 onCloseRequest
设置为 window 而不是舞台。在 OS X 上,在我点击 cmd
+ q
之后 window 最小化,但没有关闭。我想我能得到的最佳解决方案是:
//Method in my view
override fun onDock() {
super.onDock()
currentWindow?.setOnCloseRequest {
it.consume()
currentStage?.isFullScreen = true //Set the window to fullscreen again
}
}
正如我所说,这种行为是在 OS X 上发生的,我想它在各种 OS 中会有所不同...
我需要通过按 alt + f4 禁用关闭我的应用程序(它在全屏模式下运行)。我阅读了其他线程并编写了以下代码:
override fun start(stage: Stage) {
Platform.setImplicitExit(false)
stage.addEventFilter(KeyEvent.KEY_PRESSED) {
if (it.isAltDown && it.code == KeyCode.F4) {
it.consume()
}
}
stage.setOnHiding { _ -> EventHandler<WindowEvent> { it.consume() } }
stage.setOnCloseRequest { _ -> EventHandler<WindowEvent> {
it.consume()
} }
stage.fullScreenExitKeyCombination = KeyCombination.NO_MATCH
stage.fullScreenExitHint = ""
stage.isFullScreen = true
super.start(stage)
}
问题是我的应用程序没有关闭,但阶段被隐藏了。如何通过按 alf+f4 使表单不被隐藏?
我尝试将 onCloseRequest
设置为 window 而不是舞台。在 OS X 上,在我点击 cmd
+ q
之后 window 最小化,但没有关闭。我想我能得到的最佳解决方案是:
//Method in my view
override fun onDock() {
super.onDock()
currentWindow?.setOnCloseRequest {
it.consume()
currentStage?.isFullScreen = true //Set the window to fullscreen again
}
}
正如我所说,这种行为是在 OS X 上发生的,我想它在各种 OS 中会有所不同...