diff --git a/src/main/scala/org/gerweck/scalafx/util/package.scala b/src/main/scala/org/gerweck/scalafx/util/package.scala index 50d1ce4..359610a 100644 --- a/src/main/scala/org/gerweck/scalafx/util/package.scala +++ b/src/main/scala/org/gerweck/scalafx/util/package.scala @@ -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 + } + } }