disable button if there is no list rel2_10_8_6_last2
authorClaus Gittinger <cg@exept.de>
Fri, 09 Feb 1996 22:50:11 +0100
changeset 127 9d5cc59863e8
parent 126 888d8ccd35af
child 128 cd2b82b1c222
disable button if there is no list
ComboBoxV.st
ComboBoxView.st
--- a/ComboBoxV.st	Fri Feb 09 20:28:11 1996 +0100
+++ b/ComboBoxV.st	Fri Feb 09 22:50:11 1996 +0100
@@ -113,7 +113,12 @@
 !ComboBoxView methodsFor:'accessing-contents'!
 
 list:aList
-    list := aList
+    list := aList.
+    (list notNil and:[list notEmpty]) ifTrue:[
+        pullDownButton controller enable
+    ] ifFalse:[
+        pullDownButton controller disable
+    ].
 
     "Created: 9.2.1996 / 00:51:25 / cg"
     "Modified: 9.2.1996 / 00:51:56 / cg"
@@ -164,6 +169,7 @@
 
     enterField rightInset:(ext x + (ViewSpacing//2)).
 
+    pullDownButton disable.
     pullDownButton pressAction:[self pullMenu].
 
     self height:enterField preferredExtent y + ViewSpacing.
@@ -230,24 +236,25 @@
 pullMenu
     |m org|
 
-    list isNil ifTrue:[^ self].
-
-    m := PopUpMenu
-                labels:list
-                selectors:#entryChanged:
-                args:list
-                receiver:self.
+    (list notNil and:[list notEmpty]) ifTrue:[
+        m := PopUpMenu
+                    labels:list
+                    selectors:#entryChanged:
+                    args:list
+                    receiver:self.
 
-    m menuView resize.
-    m menuView width:(self width).
-    m menuView sizeFixed:true.
-    m hideOnRelease:false.
+        m menuView resize.
+        m menuView width:(self width).
+        m menuView sizeFixed:true.
+        m hideOnRelease:false.
 
-    org := device translatePoint:(0 @ self height) 
-                            from:(self id)
-                              to:(device rootView id).
+        org := device translatePoint:(0 @ self height) 
+                                from:(self id)
+                                  to:(device rootView id).
 
-    m showAt:org.
+        m showAt:org.
+    ].
+
     pullDownButton turnOff.
 
     "Created: 9.2.1996 / 00:36:49 / cg"
@@ -257,5 +264,5 @@
 !ComboBoxView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/ComboBoxV.st,v 1.3 1996-02-09 19:28:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/ComboBoxV.st,v 1.4 1996-02-09 21:50:11 cg Exp $'
 ! !
--- a/ComboBoxView.st	Fri Feb 09 20:28:11 1996 +0100
+++ b/ComboBoxView.st	Fri Feb 09 22:50:11 1996 +0100
@@ -113,7 +113,12 @@
 !ComboBoxView methodsFor:'accessing-contents'!
 
 list:aList
-    list := aList
+    list := aList.
+    (list notNil and:[list notEmpty]) ifTrue:[
+        pullDownButton controller enable
+    ] ifFalse:[
+        pullDownButton controller disable
+    ].
 
     "Created: 9.2.1996 / 00:51:25 / cg"
     "Modified: 9.2.1996 / 00:51:56 / cg"
@@ -164,6 +169,7 @@
 
     enterField rightInset:(ext x + (ViewSpacing//2)).
 
+    pullDownButton disable.
     pullDownButton pressAction:[self pullMenu].
 
     self height:enterField preferredExtent y + ViewSpacing.
@@ -230,24 +236,25 @@
 pullMenu
     |m org|
 
-    list isNil ifTrue:[^ self].
-
-    m := PopUpMenu
-                labels:list
-                selectors:#entryChanged:
-                args:list
-                receiver:self.
+    (list notNil and:[list notEmpty]) ifTrue:[
+        m := PopUpMenu
+                    labels:list
+                    selectors:#entryChanged:
+                    args:list
+                    receiver:self.
 
-    m menuView resize.
-    m menuView width:(self width).
-    m menuView sizeFixed:true.
-    m hideOnRelease:false.
+        m menuView resize.
+        m menuView width:(self width).
+        m menuView sizeFixed:true.
+        m hideOnRelease:false.
 
-    org := device translatePoint:(0 @ self height) 
-                            from:(self id)
-                              to:(device rootView id).
+        org := device translatePoint:(0 @ self height) 
+                                from:(self id)
+                                  to:(device rootView id).
 
-    m showAt:org.
+        m showAt:org.
+    ].
+
     pullDownButton turnOff.
 
     "Created: 9.2.1996 / 00:36:49 / cg"
@@ -257,5 +264,5 @@
 !ComboBoxView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.3 1996-02-09 19:28:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.4 1996-02-09 21:50:11 cg Exp $'
 ! !