Simple withKey
to bind a keyboard shortcut
This commit is contained in:
parent
484b62b0b0
commit
8e7a5a35a6
@ -8,6 +8,7 @@ import scalafx.beans.value._
|
||||
import scalafx.event.subscriptions.Subscription
|
||||
import scalafx.scene.Node
|
||||
import scalafx.scene.control._
|
||||
import scalafx.scene.input._
|
||||
import scalafx.scene.layout.GridPane
|
||||
import scalafx.util.StringConverter
|
||||
|
||||
@ -22,7 +23,6 @@ package object util extends ObservableImplicits {
|
||||
type Observable[A] = ObservableValue[A, _]
|
||||
type SimpleProperty[A] = Property[A, _]
|
||||
|
||||
|
||||
object TextDisplay {
|
||||
import scalafx.beans.property._
|
||||
import scalafx.scene.text.Text
|
||||
@ -36,4 +36,12 @@ package object util extends ObservableImplicits {
|
||||
implicit class RichGridPane(val inner: GridPane) extends AnyVal {
|
||||
def addToRow(ri: Int, children: Node*) = inner.addRow(ri, children map {_.delegate}: _*)
|
||||
}
|
||||
|
||||
implicit class RichMenuItem(val inner: MenuItem) extends AnyVal {
|
||||
def withKey(char: Char): MenuItem = {
|
||||
val c: Char = char.toUpper
|
||||
inner.accelerator = new KeyCodeCombination(KeyCode(c.toString), KeyCombination.ShortcutDown)
|
||||
inner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user