Gabriel95 / scalafx

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

Binding is not functionning with ScalaFX wrapper objects used in when-then-otherwise expressions #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. consider the basic example:
package hello

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.scene.Scene
import scalafx.scene.shape.Rectangle
import scalafx.stage.Stage

import javafx.scene.paint.Color

object World extends JFXApp {
  stage = new Stage {
    title = "Hello World"
    width = 600
    height = 450
    scene = new Scene {
      fill = Color.LIGHTGREEN
      content = new Rectangle {
        x = 25
        y = 40
        width = 100
        height = 100
        fill <== when(hover) then Color.GREEN otherwise Color.RED
      }
    }
  }
}
2. when replacing the javafx.scene.paint.Color import by its ScalaFX 
counterpart, the rectangle will be black forever
3. the same issue can be observed for other ObservaleValues based on ScalaFX 
ObjectProperty containing any SFXDelegate, while the issue does not occur when 
keeping a JavaFX object inside the same ScalaFX ObjectProperty

What is the expected output? What do you see instead?
Instead of seeing the basic example with a RED/GREEN rectangle the rectangle 
stay BLACK.

Please use labels and text to provide additional information.

This issue might be related to issue 14

Original issue reported on code.google.com by Alain.Fa...@gmail.com on 21 Dec 2012 at 4:05

GoogleCodeExporter commented 8 years ago
Fix for Issue 16 are in my repo (http://code.google.com/r/jpsacha-scalafx/) on 
the “default” branch”. Ready for inclusion in the main ScalFX repo.

It involved two modifications:
1) Property apply() methods should be implicit. Over eager implicits were 
adding extra layer of wrappers that had no reference in actual code causing 
lack of response to events.
2) Added overloaded Bindings.then for better handling of expressions containing 
wrappers (SFXDelegate)

Added tests to verify the fix works (test/issues/issue16). Also tested on 
external code including ProScalaFX (https://github.com/jsacha/ProScalaFX)

Original comment by jpsacha on 12 Jan 2013 at 6:09

GoogleCodeExporter commented 8 years ago

Original comment by Alain.Fa...@gmail.com on 17 Jan 2013 at 3:31