--- a/MenuPanel.st Wed Dec 05 10:21:03 2007 +0100
+++ b/MenuPanel.st Wed Dec 05 12:46:27 2007 +0100
@@ -3259,6 +3259,10 @@
direction := self scrollerDirectionAtPoint:motionPoint.
direction notNil ifTrue:[
self pointerEntersItem:nil.
+
+ self sensor anyButtonPressed ifTrue:[
+ self scrollActivity startIfRequiredAt:direction on:self comesViaButtonPress:false.
+ ].
^ self
].
@@ -3317,7 +3321,7 @@
direction := self scrollerDirectionAtPoint:aPoint.
direction notNil ifTrue:[
- (self scrollActivity startIfRequiredAt:direction on:self) ifTrue:[
+ (self scrollActivity startIfRequiredAt:direction on:self comesViaButtonPress:true) ifTrue:[
self pointerEntersItem:nil.
^ self
]
@@ -7799,10 +7803,10 @@
!MenuPanel::ScrollActivity methodsFor:'user operations'!
-startIfRequiredAt:aDirection on:aMenu
+startIfRequiredAt:aDirection on:aMenu comesViaButtonPress:comesViaButtonPress
"start scrolling; returns true if scrolling is activated"
- |bounds index isScrolledMenu|
+ |bounds index isScrolledMenu boundsOnRoot|
isScrolledMenu := (aDirection notNil and:[aMenu notNil and:[aMenu hasScrollers]]).
@@ -7810,7 +7814,13 @@
self stop.
isScrolledMenu ifTrue:[
- bounds := aMenu scrollerBoundsAt:aDirection.
+ bounds := aMenu scrollerBoundsAt:aDirection.
+
+ comesViaButtonPress ifFalse:[
+ boundsOnRoot := Rectangle origin:(aMenu device translatePointToRoot:(bounds origin) fromView:aMenu)
+ extent:(bounds extent).
+ ].
+
activeMenu := aMenu.
direction := aDirection.
index := aMenu indexOfItemAtScroller:aDirection.
@@ -7818,7 +7828,7 @@
index ~~ 0 ifTrue:[
scrollTask :=
[
- |item step|
+ |item step continue|
[
step := (aDirection == #PREV) ifTrue:[-1] ifFalse:[1].
@@ -7829,20 +7839,32 @@
Delay waitForSeconds:(ButtonController defaultInitialDelay).
- [ aMenu shown and:[(item := aMenu itemAt:index) notNil] ] whileTrue:[
+ [
+ continue := (aMenu shown and:[(item := aMenu itemAt:index) notNil]).
+
+ boundsOnRoot notNil ifTrue:[
+ continue ifTrue:[
+ continue := boundsOnRoot containsPoint:aMenu sensor mousePoint.
+ ] ifFalse:[
+ boundsOnRoot := nil.
+ ]
+ ].
+ continue
+ ] whileTrue:[
aMenu makeItemVisible:item.
Delay waitForSeconds:(ButtonController defaultRepeatDelay).
index := index + step.
].
item := nil.
] ensure:[
- scrollTask := nil.
+ activeMenu := direction := scrollTask := nil.
item notNil ifTrue:[
"/ process was killed
aMenu invalidate:bounds
]
- ]
+ ].
+ boundsOnRoot notNil ifTrue:[ aMenu invalidate:bounds ].
] forkAt:8.
]
]
@@ -7862,6 +7884,7 @@
activeMenu isNil ifTrue:[
^ false
].
+
semaLock critical:[
resp := activeMenu notNil.
@@ -7882,7 +7905,7 @@
!MenuPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.452 2007-10-09 22:43:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.453 2007-12-05 11:46:27 ca Exp $'
! !
MenuPanel initialize!