Created
November 1, 2015 22:18
-
-
Save clartaq/713f2c3cfc0275cac175 to your computer and use it in GitHub Desktop.
A demo of using a JavaFX keycode combination in Clojure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cljkeycodecombination.core | |
(:gen-class | |
:extends javafx.application.Application) | |
(:import | |
[javafx.application Application Platform] | |
[javafx.event EventHandler] | |
[javafx.scene Scene] | |
[javafx.scene.control Menu MenuBar MenuItem] | |
[javafx.scene.input KeyCode KeyCodeCombination KeyCombination KeyCombination$Modifier] | |
[javafx.scene.layout BorderPane] | |
[javafx.scene.paint Color])) | |
(defn -start [this stage] | |
(let [root (BorderPane.) | |
scene (Scene. root 400.0 300.0 Color/WHITE) | |
menu-bar (MenuBar.) | |
menu (Menu. "File") | |
exit-item (MenuItem. "Exit")] | |
(.setMnemonicParsing exit-item true) | |
(.setAccelerator exit-item | |
(KeyCodeCombination. | |
KeyCode/X | |
(into-array KeyCombination$Modifier [KeyCombination/SHORTCUT_DOWN]))) | |
(.setOnAction exit-item | |
(proxy [EventHandler] [] | |
(handle [event] | |
(Platform/exit)))) | |
(.add (.getItems menu) exit-item) | |
(.add (.getMenus menu-bar) menu) | |
(.setTop root menu-bar) | |
(doto stage | |
(.setTitle "KeyCodeCombination Test") | |
(.setScene scene) | |
(.show)))) | |
(defn -main [& args] | |
(Application/launch cljkeycodecombination.core args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject cljkeycodecombination "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"]] | |
:resource-paths ["c:\\Program Files\\Java\\jdk1.7.0_21\\jre\\lib\\jfxrt.jar"] | |
:aot :all | |
:main cljkeycodecombination.core) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment