MenuView.st
changeset 4692 f446e1762442
parent 4684 8886e03481ce
child 4723 c9e6f680c6e3
--- a/MenuView.st	Thu Aug 29 18:45:54 2013 +0200
+++ b/MenuView.st	Thu Aug 29 19:03:51 2013 +0200
@@ -419,9 +419,11 @@
 
     |index|
 
+    enableFlags isNil ifTrue:[^ true].
+    indexOrName isNumber ifTrue:[ ^ enableFlags at: indexOrName ].
+
     index := self indexOf:indexOrName.
     index ~~ 0 ifTrue:[
-        enableFlags isNil ifTrue:[^ true].
         ^ enableFlags at:index
     ].
     "ask submenus for convenience"
@@ -440,6 +442,11 @@
 
     |index|
 
+    enableFlags isNil ifTrue:[
+        aBoolean ifTrue:[ ^ self ].
+        enableFlags := Array new: list size
+    ].
+
     index := self indexOf:indexOrName.
     index ~~ 0 ifTrue:[
         (enableFlags at:index) ~~ aBoolean ifTrue:[
@@ -1311,18 +1318,18 @@
     i == 0 ifTrue:[^ self].
     list := list asOrderedCollection removeIndex:i.
     selectors := selectors asOrderedCollection removeIndex:i.
-    enableFlags := enableFlags asOrderedCollection removeIndex:i.
+    enableFlags notNil ifTrue:[ enableFlags := enableFlags asOrderedCollection removeIndex:i ].
     subMenus notNil ifTrue:[
-	subMenus := subMenus asOrderedCollection removeIndex:i.
+        subMenus := subMenus asOrderedCollection removeIndex:i.
     ].
     shortKeys notNil ifTrue:[
-	shortKeys := shortKeys asOrderedCollection removeIndex:i.
-	maxShortKeyStringLen := nil.
+        shortKeys := shortKeys asOrderedCollection removeIndex:i.
+        maxShortKeyStringLen := nil.
     ].
     shown ifTrue:[
-	self resize
+        self resize
     ] ifFalse:[
-	needResize := true
+        needResize := true
     ]
 
     "Modified: 28.2.1996 / 18:27:57 / cg"
@@ -2426,7 +2433,7 @@
     newSelection := self positionToSelectionX:x y:y.
     newSelection ~= selection ifTrue:[
         newSelection notNil ifTrue:[
-            (enableFlags at:newSelection) ifFalse:[
+            (self isEnabled:newSelection) ifFalse:[
                 newSelection := nil
             ]
         ].
@@ -2625,7 +2632,7 @@
 
             (special
             or:[shortKeys notNil
-            or:[(enableFlags at:index) not]]) ifTrue:[
+            or:[(self isEnabled:index) not]]) ifTrue:[
                 "a special case"
                 (first < current) ifTrue:[
                     super redrawFromVisibleLine:first to:(current - 1)
@@ -2686,7 +2693,7 @@
 
     isSpecial ifFalse:[
         lineNr := self visibleLineToListLine:visLineNr.
-        (enableFlags at:lineNr) ifFalse:[
+        (self isEnabled:lineNr) ifFalse:[
             text := self visibleAt:visLineNr.
             disabledEtchedFgColor notNil ifTrue:[
                 text := text asText emphasisAllAdd:(#etchColor -> disabledEtchedFgColor)
@@ -2799,7 +2806,7 @@
     |line|
 
     (super isValidSelection:aNumber) ifFalse:[^ false].
-    (enableFlags at:aNumber) ifFalse:[^ false].
+    (self isEnabled:aNumber) ifFalse:[^ false].
 
     line := self listAt:aNumber.
     ^ (self isGraphicItem:line) not
@@ -2993,10 +3000,10 @@
 !MenuView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.180 2013-08-28 12:02:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.181 2013-08-29 17:03:51 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.180 2013-08-28 12:02:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.181 2013-08-29 17:03:51 cg Exp $'
 ! !