Add new automatic conversion to BooleanProperty
There are a number of signatures in ScalaFX that won't accept an observable of a Scala Boolean and that require you to convert it to a Java Boolean. This adds an automatic conversion to resolve that.
This commit is contained in:
parent
e50159b82e
commit
5b6ad07a08
@ -0,0 +1,15 @@
|
|||||||
|
package org.gerweck.scalafx.util
|
||||||
|
|
||||||
|
import scala.language.implicitConversions
|
||||||
|
|
||||||
|
import scalafx.beans.property._
|
||||||
|
|
||||||
|
trait LowPriorityImplicits {
|
||||||
|
implicit def scalaBooleanToBooleanProperty(ob: ReadOnlyObjectProperty[Boolean]): ReadOnlyBooleanProperty = {
|
||||||
|
val b = BooleanProperty(ob.value)
|
||||||
|
ob onChange { (_, oldV, newV) =>
|
||||||
|
b.value = newV
|
||||||
|
}
|
||||||
|
b
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package org.gerweck.scalafx
|
|||||||
import language.implicitConversions
|
import language.implicitConversions
|
||||||
import language.existentials
|
import language.existentials
|
||||||
|
|
||||||
|
import scalafx.Includes._
|
||||||
import scalafx.beans.property._
|
import scalafx.beans.property._
|
||||||
import scalafx.beans.value._
|
import scalafx.beans.value._
|
||||||
import scalafx.event.subscriptions.Subscription
|
import scalafx.event.subscriptions.Subscription
|
||||||
@ -19,7 +20,7 @@ import scalaz._
|
|||||||
*
|
*
|
||||||
* @author Sarah Gerweck <sarah@atscale.com>
|
* @author Sarah Gerweck <sarah@atscale.com>
|
||||||
*/
|
*/
|
||||||
package object util extends ObservableImplicits {
|
package object util extends ObservableImplicits with LowPriorityImplicits {
|
||||||
type Observable[A] = ObservableValue[A, _]
|
type Observable[A] = ObservableValue[A, _]
|
||||||
type SimpleProperty[A] = Property[A, _]
|
type SimpleProperty[A] = Property[A, _]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user