tornadofx使用menubar控件

class LearnApp : App(LearnV::class)
class LearnV : View("learn") {
    val menuClicked = stringProperty()
    override val root = borderpane {
        top{
            menubar {
                isUseSystemMenuBar = true

                menu("Application") {
                    item(
                        name = "Restart",
                        keyCombination = KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN)
                    ).action {
                        menuClicked.value="Restart"
                    }
                    item(
                        name = "Pause",
                        keyCombination = KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN)
                    ).apply {
                        action {
                            menuClicked.value=this.text
                        }
                    }
                    item("Quit",KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN)){
                        action {
                            menuClicked.value=this.text
                        }
                    }
                }
            }
        }
        bottom {
            form{
                fieldset {
                    field("menu clicked") {
                        label(menuClicked)
                    }
                }
            }
        }
        prefWidth=200.0
        prefHeight=200.0
    }
}
相關文章
相關標籤/搜索