immediately change fg color when enableChannel is set
authorClaus Gittinger <cg@exept.de>
Wed, 24 Jan 1996 20:46:40 +0100
changeset 119 913df6ba1ccc
parent 118 2821a094ba30
child 120 daf50b3a54ff
immediately change fg color when enableChannel is set
CheckBox.st
--- a/CheckBox.st	Mon Jan 15 20:48:45 1996 +0100
+++ b/CheckBox.st	Wed Jan 24 20:46:40 1996 +0100
@@ -149,19 +149,19 @@
 
      translator := Plug new.
      translator respondTo:#enableDisable 
-                with:[
-                        enableChannel value
-                            ifTrue:[
-                                box1 enable.
-                                box2 enable.
-                                box3 enable.
-                            ]
-                            ifFalse:[
-                                box1 disable.
-                                box2 disable.
-                                box3 disable.
-                            ]
-                     ].
+		with:[
+			enableChannel value
+			    ifTrue:[
+				box1 enable.
+				box2 enable.
+				box3 enable.
+			    ]
+			    ifFalse:[
+				box1 disable.
+				box2 disable.
+				box3 disable.
+			    ]
+		     ].
 
      enableChannel := true asValue.
      enableChannel onChangeSend:#enableDisable to:translator.
@@ -214,8 +214,8 @@
      top openModal.
 
      top accepted ifTrue:[
-         Transcript show:'value1: '; showCr:model value1.
-         Transcript show:'value2: '; showCr:model value2.
+	 Transcript show:'value1: '; showCr:model value1.
+	 Transcript show:'value2: '; showCr:model value2.
      ]
 "
 ! !
@@ -328,10 +328,17 @@
 !CheckBox methodsFor:'accessing-channels'!
 
 enableChannel:aChannel
+    |wasEnabled|
+
+    wasEnabled := toggleView enabled.
     toggleView enableChannel:aChannel.
-    aChannel onChangeSend:#enableStateChanged to:self
+    aChannel onChangeSend:#enableStateChanged to:self.
+    aChannel value ~~ wasEnabled ifTrue:[
+	self enableStateChanged
+    ]
 
     "Created: 17.12.1995 / 16:07:59 / cg"
+    "Modified: 24.1.1996 / 20:17:24 / cg"
 ! !
 
 !CheckBox methodsFor:'accessing-look'!
@@ -425,13 +432,16 @@
 !CheckBox methodsFor:'change & update'!
 
 enableStateChanged
+    |clr|
+
     toggleView enabled ifTrue:[
-        labelView foregroundColor:(self labelForegroundColor)
+	clr := self labelForegroundColor
     ] ifFalse:[
-        labelView foregroundColor:(self disabledLabelForegroundColor)
+	clr := self disabledLabelForegroundColor
     ].
+    labelView foregroundColor:clr
 
-    "Modified: 17.12.1995 / 16:09:27 / cg"
+    "Modified: 24.1.1996 / 20:04:34 / cg"
 ! !
 
 !CheckBox methodsFor:'initialization'!
@@ -440,10 +450,10 @@
     super initStyle.
 
     DefaultLabelForegroundColor notNil ifTrue:[
-        labelForegroundColor := DefaultLabelForegroundColor on:device.
+	labelForegroundColor := DefaultLabelForegroundColor on:device.
     ].
     DefaultDisabledLabelForegroundColor notNil ifTrue:[
-        disabledLabelForegroundColor := DefaultDisabledLabelForegroundColor on:device.
+	disabledLabelForegroundColor := DefaultDisabledLabelForegroundColor on:device.
     ].
 
     "Created: 14.12.1995 / 14:50:03 / cg"
@@ -503,5 +513,5 @@
 !CheckBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.17 1995-12-17 15:15:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/CheckBox.st,v 1.18 1996-01-24 19:46:40 cg Exp $'
 ! !