diff options
Diffstat (limited to 'src/swing')
-rw-r--r-- | src/swing/scala/swing/ListView.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/Slider.scala | 9 | ||||
-rw-r--r-- | src/swing/scala/swing/TextComponent.scala | 9 | ||||
-rw-r--r-- | src/swing/scala/swing/TextField.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/event/EditDone.scala | 3 | ||||
-rw-r--r-- | src/swing/scala/swing/event/ValueChanged.scala | 2 | ||||
-rw-r--r-- | src/swing/scala/swing/test/CelsiusConverter.scala | 5 | ||||
-rw-r--r-- | src/swing/scala/swing/test/CelsiusConverter2.scala | 4 | ||||
-rw-r--r-- | src/swing/scala/swing/test/UIDemo.scala | 6 |
9 files changed, 26 insertions, 18 deletions
diff --git a/src/swing/scala/swing/ListView.scala b/src/swing/scala/swing/ListView.scala index 0460074dd9..6d9a6354bf 100644 --- a/src/swing/scala/swing/ListView.scala +++ b/src/swing/scala/swing/ListView.scala @@ -166,6 +166,8 @@ class ListView[A] extends Component { publish(ListSelectionChanged(ListView.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting)) } }) + + def adjusting = peer.getSelectionModel.getValueIsAdjusting } def renderer: ListView.Renderer[A] = ListView.Renderer.wrap(peer.getCellRenderer) diff --git a/src/swing/scala/swing/Slider.scala b/src/swing/scala/swing/Slider.scala index 348fdc0c4e..d03704f482 100644 --- a/src/swing/scala/swing/Slider.scala +++ b/src/swing/scala/swing/Slider.scala @@ -1,9 +1,12 @@ package scala.swing import event._ -import Swing._ /** + * + * Fires a ValueChanged event whenever the slider's value changes and + * when the knob is released. + * * @see javax.swing.JSlider */ class Slider extends Component with Orientable with Publisher { @@ -33,6 +36,8 @@ class Slider extends Component with Orientable with Publisher { def majorTickSpacing: Int = peer.getMajorTickSpacing def majorTickSpacing_=(v: Int) { peer.setMajorTickSpacing(v) } + def adjusting = peer.getValueIsAdjusting + def labels: scala.collection.Map[Int, Label] = new scala.collection.jcl.MapWrapper[Int, Label] { def underlying = peer.getLabelTable.asInstanceOf[java.util.Hashtable[Int, Label]] } def labels_=(l: scala.collection.Map[Int, Label]) { @@ -43,7 +48,7 @@ class Slider extends Component with Orientable with Publisher { peer.addChangeListener(new javax.swing.event.ChangeListener { def stateChanged(e: javax.swing.event.ChangeEvent) { - publish(ValueChanged(Slider.this)(peer.getValueIsAdjusting)) + publish(ValueChanged(Slider.this)) } }) }
\ No newline at end of file diff --git a/src/swing/scala/swing/TextComponent.scala b/src/swing/scala/swing/TextComponent.scala index 712c524978..3be31809d7 100644 --- a/src/swing/scala/swing/TextComponent.scala +++ b/src/swing/scala/swing/TextComponent.scala @@ -56,9 +56,8 @@ class TextComponent extends Component with Publisher { def selectAll() { peer.selectAll() } peer.getDocument.addDocumentListener(new DocumentListener { - def changedUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)(true)) } - def insertUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)(true)) } - def removeUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)(true)) } + def changedUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)) } + def insertUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)) } + def removeUpdate(e:DocumentEvent) { publish(ValueChanged(TextComponent.this)) } }) -} - +}
\ No newline at end of file diff --git a/src/swing/scala/swing/TextField.scala b/src/swing/scala/swing/TextField.scala index d32aa8fa4d..3565f64b3f 100644 --- a/src/swing/scala/swing/TextField.scala +++ b/src/swing/scala/swing/TextField.scala @@ -29,11 +29,11 @@ class TextField(text0: String, columns0: Int) extends TextComponent with TextCom def columns_=(n: Int) = peer.setColumns(n) peer.addActionListener(Swing.ActionListener { e => - publish(ValueChanged(TextField.this)(false)) + publish(EditDone(TextField.this)) }) peer.addFocusListener(new FocusAdapter { - override def focusLost(e: java.awt.event.FocusEvent) { ValueChanged(TextField.this)(true) } + override def focusLost(e: java.awt.event.FocusEvent) { EditDone(TextField.this) } }) def verifier: String => Boolean = s => peer.getInputVerifier.verify(peer) diff --git a/src/swing/scala/swing/event/EditDone.scala b/src/swing/scala/swing/event/EditDone.scala new file mode 100644 index 0000000000..b802a1a981 --- /dev/null +++ b/src/swing/scala/swing/event/EditDone.scala @@ -0,0 +1,3 @@ +package scala.swing.event + +case class EditDone(override val source: TextField) extends ValueChanged(source) diff --git a/src/swing/scala/swing/event/ValueChanged.scala b/src/swing/scala/swing/event/ValueChanged.scala index 991a6b6570..1097a52da2 100644 --- a/src/swing/scala/swing/event/ValueChanged.scala +++ b/src/swing/scala/swing/event/ValueChanged.scala @@ -1,3 +1,3 @@ package scala.swing.event -case class ValueChanged(override val source: Component)(val adjusting: Boolean) extends ComponentEvent with AdjustingEvent +case class ValueChanged(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/test/CelsiusConverter.scala b/src/swing/scala/swing/test/CelsiusConverter.scala index a4c1921606..fc5c1e4553 100644 --- a/src/swing/scala/swing/test/CelsiusConverter.scala +++ b/src/swing/scala/swing/test/CelsiusConverter.scala @@ -29,15 +29,14 @@ object CelsiusConverter extends SimpleGUIApplication { } reactions += { - case ButtonClicked(_) => convert() - case v @ ValueChanged(_) if v.committed => convert() + case ButtonClicked(_) | EditDone(_) => convert() } } contents = new GridPanel(2,2) { contents.append(tempCelsius, celsiusLabel, convertButton, fahrenheitLabel) border = Swing.EmptyBorder(10, 10, 10, 10) } - defaultButton = Some(convertButton) + //defaultButton = Some(convertButton) } } diff --git a/src/swing/scala/swing/test/CelsiusConverter2.scala b/src/swing/scala/swing/test/CelsiusConverter2.scala index 0b382ba96b..a7a6f427ee 100644 --- a/src/swing/scala/swing/test/CelsiusConverter2.scala +++ b/src/swing/scala/swing/test/CelsiusConverter2.scala @@ -13,11 +13,11 @@ object CelsiusConverter2 extends SimpleGUIApplication { listenTo(Fahrenheit, Celsius) reactions += { - case v @ ValueChanged(Fahrenheit) if v.committed => + case EditDone(Fahrenheit) => val f = Integer.parseInt(Fahrenheit.text) val c = (f - 32) * 5 / 9 Celsius.text = c.toString - case v @ ValueChanged(Celsius) if v.committed => + case EditDone(Celsius) => val c = Integer.parseInt(Celsius.text) val f = c * 9 / 5 + 32 Fahrenheit.text = f.toString diff --git a/src/swing/scala/swing/test/UIDemo.scala b/src/swing/scala/swing/test/UIDemo.scala index 8c94b94975..716bdd6694 100644 --- a/src/swing/scala/swing/test/UIDemo.scala +++ b/src/swing/scala/swing/test/UIDemo.scala @@ -85,7 +85,7 @@ object UIDemo extends SimpleGUIApplication { contents += label listenTo(field) reactions += { - case v @ ValueChanged(`field`) if v.committed => label.text = field.password.mkString + case EditDone(`field`) => label.text = field.password.mkString } } @@ -116,8 +116,8 @@ object UIDemo extends SimpleGUIApplication { listenTo(tabs.selection) listenTo(list.selection) reactions += { - case v @ ValueChanged(`slider`) => - if(v.committed || reactLive) tabs.selection.index = slider.value + case ValueChanged(`slider`) => + if(!slider.adjusting || reactLive) tabs.selection.index = slider.value case SelectionChanged(`tabs`) => slider.value = tabs.selection.index list.selection.selectIndices(tabs.selection.index) |