--- a/MenuPanel.st Mon Mar 05 09:08:56 2007 +0100
+++ b/MenuPanel.st Mon Mar 05 13:46:53 2007 +0100
@@ -1993,9 +1993,19 @@
!MenuPanel methodsFor:'accessing-submenu'!
subMenuAt:stringOrNumber
- "gets the submenu of an item or nil"
-
- ^ self itemAt:stringOrNumber do:[:el| el submenu ]
+ "gets the current submenu of an item; if the submenu is nil, the
+ submenu is generated if specified otherwise nil is returned."
+
+ |submenu|
+
+
+ self itemAt:stringOrNumber do:[:anItem|
+ submenu := anItem currentSubmenu.
+ submenu isNil ifTrue:[
+ submenu := anItem setupSubmenu
+ ].
+ ].
+ ^ submenu
!
subMenuAt:stringOrNumber put:aSubMenu
@@ -2007,10 +2017,16 @@
subMenuShown
"return the currently visible submenu - or nil if there is none"
- |item|
-
- (item := self selection) notNil ifTrue:[
- ^ item submenu
+ |item submenu|
+
+ item := self selection.
+
+ item notNil ifTrue:[
+ submenu := item currentSubmenu.
+
+ (submenu notNil and:[submenu shown]) ifTrue:[
+ ^ submenu
+ ].
].
^ nil
! !
@@ -4198,22 +4214,23 @@
|menu item|
indices size == 0 ifTrue:[
- ^ self
+ ^ self
].
menu := self.
+ "/ first lookup in current open submenus
[menu selectionIndex == indices first] whileTrue:[
- ( (item := menu selection) isNil "/ shouldn't happen
- or:[(menu := item submenu) isNil] "/ no more indices; done
- ) ifTrue:[
- ^ true
- ].
- indices removeFirst.
-
- indices isEmpty ifTrue:[
- menu selection:nil.
- ^ self
- ]
+ ( (item := menu selection) isNil
+ or:[(menu := item currentSubmenu) isNil]
+ ) ifTrue:[ "/ selected but no submenu open - not handled
+ ^ self
+ ].
+ indices removeFirst.
+
+ indices isEmpty ifTrue:[
+ menu selection:nil.
+ ^ self
+ ]
].
menu openMenusFromItemIndices:indices.
!
@@ -4234,7 +4251,7 @@
"/ fast check, cursor keys are not supported
- ( #( CursorDown CursorUp CursorRight CursorLeft
+ ( #( CursorDown CursorUp CursorRight CursorLeft Return Escape
) includes:lKey
) ifTrue:[
^ false.
@@ -4302,7 +4319,7 @@
(item hasSubmenu and:[item hasDelayedMenu not]) ifTrue:[
(item enabled and:[item isVisible]) ifTrue:[
(ignoreSubmenueBlock isNil or:[(ignoreSubmenueBlock value:item) not]) ifTrue:[
- menu := item submenu.
+ menu := item setupSubmenu.
(menu notNil and:[menu isEnabled]) ifTrue:[
result := menu selectItemIndicesFor:aOneArgBlock
@@ -7098,9 +7115,7 @@
|s i rest label pos|
- (accessCharacter notNil or:[aLabel isNil]) ifTrue:[
- ^ aLabel
- ].
+ accessCharacter notNil ifTrue:[^ aLabel].
aLabel isString ifFalse:[
aLabel class == LabelAndIcon ifTrue:[
@@ -7108,7 +7123,6 @@
].
^ aLabel
].
-
s := aLabel size.
i := 1.
@@ -7833,7 +7847,7 @@
!MenuPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.444 2007-03-02 17:12:04 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.445 2007-03-05 12:46:53 ca Exp $'
! !
MenuPanel initialize!