--- a/MenuPanel.st Wed May 22 18:07:59 2019 +0200
+++ b/MenuPanel.st Mon May 27 17:06:52 2019 +0200
@@ -61,7 +61,7 @@
Object subclass:#ScrollActivity
instanceVariableNames:'semaLock activeMenu scrollTask direction icons'
- classVariableNames:''
+ classVariableNames:'Icons'
poolDictionaries:''
privateIn:MenuPanel
!
@@ -1108,7 +1108,7 @@
prevFocusView := nil.
self openDelayed:nil.
- self scrollActivity stop.
+ self stopScrollActivity.
self selection:nil.
(anItemOrNil notNil and:[anItemOrNil canAccept]) ifTrue:[
@@ -1196,6 +1196,7 @@
"/ ].
"Modified: / 07-07-2011 / 18:08:41 / cg"
+ "Modified: / 27-05-2019 / 16:08:42 / Claus Gittinger"
!
acceptIsUserAction:isUserAction
@@ -2946,16 +2947,16 @@
drawScrollerAt:aDirection bounds:bounds
"draw a scroller"
- |scrolling icon level x y w h|
+ |icon level x y w h scroll|
x := bounds left.
y := bounds top.
w := bounds width.
h := bounds height.
- scrolling := self scrollActivity.
-
- (scrolling activeMenu == self and:[scrolling direction == aDirection]) ifTrue:[
+ ((scroll := self scrollActivityOrNil) notNil
+ and:[scroll activeMenu == self
+ and:[scroll direction == aDirection]]) ifTrue:[
level := styleSheet at:'menuPanel.scrollButtonActiveLevel' default:-2
] ifFalse:[
level := styleSheet at:'menuPanel.scrollButtonPassiveLevel' default:1
@@ -2964,16 +2965,16 @@
self isPopUpView ifFalse:[
self verticalLayout ifFalse:[
aDirection == #NEXT ifTrue:[
- icon := scrolling class iconScrollRightM
+ icon := ScrollActivity iconScrollRightM
] ifFalse:[
aDirection == #PREV ifTrue:[
- icon := scrolling class iconScrollLeftM
+ icon := ScrollActivity iconScrollLeftM
]
]
]
].
icon isNil ifTrue:[
- icon := scrolling iconAt:aDirection on:self.
+ icon := ScrollActivity iconAt:aDirection on:self.
].
icon displayOn:self x:(x + ((w - icon width) // 2))
@@ -2993,6 +2994,8 @@
"/ ].
"/ ].
].
+
+ "Modified: / 27-05-2019 / 16:09:40 / Claus Gittinger"
!
invalidateItem:anItem repairNow:aBool
@@ -3420,7 +3423,7 @@
|menu motionPoint translatedPoint sensor anyButtonPressed|
- self scrollActivity isActive ifTrue:[
+ (self scrollActivityIsActive) ifTrue:[
^ self
].
@@ -3456,13 +3459,13 @@
].
"Modified: / 13-11-2001 / 20:21:49 / cg"
- "Modified: / 02-03-2019 / 12:11:40 / Claus Gittinger"
+ "Modified: / 27-05-2019 / 16:11:04 / Claus Gittinger"
!
buttonPress:button x:x y:y
"any button pressed; open or close the corresponding submenus"
- |menu point screen screenPoint targetView targetPoint wg|
+ |menu point screen screenPoint targetView targetPoint wg scroll|
hideOnRelease := true.
@@ -3472,7 +3475,12 @@
wg focusMomentaryRelease.
].
- self scrollActivity stop.
+ (scroll := self scrollActivityOrNil) notNil ifTrue:[
+ scroll stop ifTrue:[
+ ^ self
+ ].
+ ].
+
point := x@y.
menu := self detectMenuAtGrabPoint:point.
@@ -3496,6 +3504,7 @@
]
"Modified: / 02-10-2011 / 09:20:08 / cg"
+ "Modified: / 27-05-2019 / 16:11:45 / Claus Gittinger"
!
buttonRelease:button x:x y:y
@@ -3510,9 +3519,10 @@
topMenu := self topMenu.
topMenu openDelayed:nil.
- self scrollActivity stop ifTrue:[
+ self stopScrollActivity ifTrue:[
^ self
].
+
dstMenu := topMenu activeMenu.
hideMenuAndPerformAction := dstMenu selection notNil or:[dstMenu isPopUpView not].
@@ -3577,6 +3587,8 @@
].
self accept:nil.
].
+
+ "Modified: / 27-05-2019 / 16:14:16 / Claus Gittinger"
!
handleSizeChanged:how
@@ -3661,11 +3673,11 @@
"/ ^ self "/ ignored while any button is pressed
"/ ].
- self scrollActivity isActive ifTrue:[
+ (self scrollActivityIsActive) ifTrue:[
key ~~ #Escape ifTrue:[
^ self
].
- self scrollActivity stop
+ self stopScrollActivity.
].
(key == #Tab
@@ -3709,6 +3721,7 @@
super keyPress:key x:x y:y
"Modified: / 17-08-2017 / 09:05:43 / cg"
+ "Modified: / 27-05-2019 / 16:14:41 / Claus Gittinger"
!
mapped
@@ -3743,7 +3756,7 @@
pointerLeave:state
|sensor|
- self scrollActivity isActive ifTrue:[^ self].
+ (self scrollActivityIsActive) ifTrue:[^ self].
self detectGrabMenu handlePointerLeave:state.
@@ -3769,6 +3782,8 @@
].
]
].
+
+ "Modified: / 27-05-2019 / 16:14:53 / Claus Gittinger"
!
sizeChanged:how
@@ -5843,7 +5858,7 @@
!
scrollActivity
- "returns the one and only scrollActivity - data holder
+ "returns the one and only per-menu scrollActivity - data holder
for a menu and all contained submenus"
superMenu notNil ifTrue:[
@@ -5853,6 +5868,27 @@
scrollActivity := ScrollActivity new.
].
^ scrollActivity
+
+ "Modified (comment): / 27-05-2019 / 16:15:08 / Claus Gittinger"
+!
+
+scrollActivityIsActive
+ superMenu notNil ifTrue:[
+ ^ superMenu scrollActivityIsActive
+ ].
+ ^ scrollActivity notNil
+ and:[ scrollActivity isActive ].
+
+ "Created: / 27-05-2019 / 16:10:08 / Claus Gittinger"
+!
+
+scrollActivityOrNil
+ superMenu notNil ifTrue:[
+ ^ superMenu scrollActivityOrNil
+ ].
+ ^ scrollActivity
+
+ "Created: / 27-05-2019 / 16:06:14 / Claus Gittinger"
!
scrollDown
@@ -5956,6 +5992,21 @@
^ nil
"Created: / 13.11.2001 / 14:13:16 / cg"
+!
+
+stopScrollActivity
+ |ret|
+
+ superMenu notNil ifTrue:[
+ ^ superMenu stopScrollActivity
+ ].
+
+ scrollActivity isNil ifTrue:[^ false].
+ ret := scrollActivity stop.
+ scrollActivity := nil.
+ ^ ret
+
+ "Created: / 27-05-2019 / 16:08:23 / Claus Gittinger"
! !
!MenuPanel methodsFor:'private-searching'!
@@ -7319,7 +7370,7 @@
"/ the assoc's key is the helpSpec provider (a class),
"/ and the assoc's value is the key in there
Error handle:[:ex |
- Logger warn:'caught error in helpTextForKey: ',ex description
+ Logger warning:'caught error in helpTextForKey: %1' with:ex description
] do:[
text := key1 key helpTextForKey:key1 value.
].
@@ -7364,8 +7415,7 @@
].
^ text
- "Modified: / 09-11-2018 / 08:54:58 / Claus Gittinger"
- "Modified (comment): / 27-02-2019 / 11:33:19 / Claus Gittinger"
+ "Modified: / 27-05-2019 / 16:20:53 / Claus Gittinger"
!
activeHelpText:aText
@@ -9323,6 +9373,35 @@
icon
^ self iconGrey
+!
+
+iconAt:aDirection on:aMenu
+ |icon index|
+
+ aDirection == #PREV ifTrue:[
+ aMenu verticalLayout ifTrue:[index := 3] "/ 3 - 1 * 90 180
+ ifFalse:[index := 2] "/ 2 - 1 * 90 90
+ ] ifFalse:[
+ aMenu verticalLayout ifTrue:[index := 1] "/ 1 - 1 * 90 0
+ ifFalse:[index := 4] "/ 4 - 1 * 90 270
+ ].
+
+ Icons isNil ifTrue:[
+ Icons := Array new:4.
+ ].
+ icon := Icons at:index.
+
+ (icon isNil) ifTrue:[
+ icon := self icon.
+ index > 1 ifTrue:[ icon := icon rotated:((index - 1) * 90) ]
+ ifFalse:[ icon := icon copy ].
+
+ icon := icon onDevice:aMenu device.
+ Icons at:index put:icon
+ ].
+ ^ icon
+
+ "Created: / 27-05-2019 / 15:56:51 / Claus Gittinger"
! !
!MenuPanel::ScrollActivity class methodsFor:'image specs'!
@@ -9499,8 +9578,6 @@
iconAt:aDirection on:aMenu
|icon menusDevice index|
- menusDevice := aMenu device.
-
aDirection == #PREV ifTrue:[
aMenu verticalLayout ifTrue:[index := 3] "/ 3 - 1 * 90 180
ifFalse:[index := 2] "/ 2 - 1 * 90 90
@@ -9508,20 +9585,19 @@
aMenu verticalLayout ifTrue:[index := 1] "/ 1 - 1 * 90 0
ifFalse:[index := 4] "/ 4 - 1 * 90 270
].
-
icon := icons at:index.
-
- (icon isNil or:[icon device ~~ menusDevice]) ifTrue:[
- icon := self class icon.
- index > 1 ifTrue:[ icon := icon rotated:((index - 1) * 90) ]
- ifFalse:[ icon := icon copy ].
-
- icon := icon onDevice:menusDevice.
- icons at:index put:icon
+ icon isNil ifTrue:[
+ menusDevice := aMenu device.
+ icon := self class iconAt:aDirection on:aMenu.
+ (icon isNil or:[icon device ~~ menusDevice]) ifTrue:[
+ icon := icon onDevice:menusDevice.
+ icons at:index put:icon
+ ].
].
^ icon
"Modified (format): / 16-11-2016 / 23:12:59 / cg"
+ "Modified: / 27-05-2019 / 15:58:47 / Claus Gittinger"
! !
!MenuPanel::ScrollActivity methodsFor:'initialization'!
@@ -9610,7 +9686,8 @@
!
stop
- "stop scrolling; returns true if the scrolling was activated otherwise false"
+ "stop scrolling;
+ returns true if the scrolling was activated otherwise false"
|task resp|
@@ -9625,6 +9702,7 @@
scrollTask := nil.
Error handle:[:ex|
+ Transcript showCR:ex.
] do:[
task terminateWithAllSubprocessesInGroup.
task waitUntilTerminated.
@@ -9633,6 +9711,8 @@
activeMenu := direction := nil.
].
^ resp
+
+ "Modified (comment): / 27-05-2019 / 16:04:22 / Claus Gittinger"
! !
!MenuPanel class methodsFor:'documentation'!