Gabriel95 / scalafx

Automatically exported from code.google.com/p/scalafx
Other
0 stars 0 forks source link

ComboBox value property is not a scalafx property #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Since ComboBox.value property is not a scalafx Property instance it doesn't 
support the <==> binding operator. This would be nice to have.

Original issue reported on code.google.com by jbiver...@gmail.com on 5 Nov 2012 at 12:48

GoogleCodeExporter commented 8 years ago
Actually ComboBox already has a value property. However it is in its superclass 
ComboBoxProperty. Anyway, it supports <==> operator. To prove it, run this code:

{{{
package scalafx

import beans.property._
import Includes._
import scene.control._

object scalafx {
  val stringProp = StringProperty("gama")         //> stringProp  : scalafx.beans.property.StringProperty = [SFX]StringProperty [v
                                                  //| alue: gama]

  val comboBox: ComboBoxBase[String] = new ComboBox[String](List("alpha", "beta", "gama", "delta")) {
    value <==> stringProp
  }                                               //> comboBox  : scalafx.scene.control.ComboBoxBase[String] = [SFX]ComboBox@21994
                                                  //| 57f[styleClass=combo-box-base combo-box]

  def showValues {
    println("Combo:   " + comboBox.value.value)
    println("strProp: " + stringProp.value)
  }                                               //> showValues: => Unit

  showValues                                      //> Combo:   gama
                                                  //| strProp: gama
  comboBox.value = "alpha"

  showValues                                      //> Combo:   alpha
                                                  //| strProp: alpha
  stringProp.value = "beta"

  showValues                                      //> Combo:   beta
                                                  //| strProp: beta

  comboBox.value = "omega"

  showValues                                      //> Combo:   omega
                                                  //| strProp: omega

  stringProp.value = "psi"

  showValues                                      //> Combo:   psi
                                                  //| strProp: psi
}
}}}

Original comment by rafael.a...@gmail.com on 10 Feb 2013 at 2:10