--- a/MenuPanel.st Thu May 22 00:59:55 2008 +0200
+++ b/MenuPanel.st Fri May 23 15:03:41 2008 +0200
@@ -1990,6 +1990,11 @@
^ buttonInsetY
!
+drawMenuIndicatorSeparatorLine
+^ true.
+ ^ styleSheet at:#'menu.drawMenuIndicatorSeparatorLine' default:false
+!
+
enteredLevel
"returns the enter-level for an unselected item moved through"
@@ -2014,6 +2019,13 @@
^ itemSpace
!
+menuIndicatorVerticalPosition
+ "#center, #top or #bottom"
+
+ ^ #center
+ "/ ^ styleSheet at:#'menu.menuIndicatorVerticalPosition' default:#bottom
+!
+
selectionFollowsMouse
"returns true if the selection follows the mouse"
@@ -2531,7 +2543,7 @@
layout := anItem layout.
(layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[
- self invalidate:(layout copy insetBy:-1) repairNow:aBool
+ self invalidate:(layout "insetBy:-1") repairNow:aBool
]
].
@@ -2591,6 +2603,7 @@
anItem layout moveBy:point.
]
].
+ self updateEnteredItem.
"Modified: / 10-10-2007 / 00:29:34 / cg"
!
@@ -2614,6 +2627,7 @@
itemMargin "{ Class:SmallInteger }"
groupDividerSize "{ Class:SmallInteger }"
|
+
(mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[
mustRearrange := false.
^ self
@@ -2808,6 +2822,18 @@
].
"Modified: / 15.11.2001 / 20:57:32 / cg"
+!
+
+updateEnteredItem
+ |mousePoint|
+
+ mousePoint := device translatePoint:(device pointerPosition)
+ fromView:nil
+ toView:self.
+
+ (self containsPoint:mousePoint) ifTrue:[
+ enteredItem := self itemAtPoint:mousePoint
+ ].
! !
!MenuPanel methodsFor:'enumerting & searching'!
@@ -2977,10 +3003,9 @@
menuMapTime := dstMenu mapTime ? releaseTime.
hideMenuAndPerformAction := (releaseTime millisecondDeltaFrom:menuMapTime)
- > (PopUpMenu maxClickTimeToStayOpen).
- ].
- ].
-
+ > (PopUpMenu maxClickTimeToStayOpen).
+ ].
+ ].
hideMenuAndPerformAction ifTrue:[
srcPoint := x@y.
@@ -2989,12 +3014,10 @@
) ifTrue:[
item visibleSubmenu notNil ifTrue:[
dstMenu selection:nil.
-
(selection isNil and:[self isPopUpView not]) ifTrue:[
- self accept:nil
+ self accept:nil.
].
^ self
-
].
subm := item currentSubmenu.
@@ -3284,8 +3307,10 @@
|menu item translatedPoint containsPoint direction|
- containsPoint := self containsPoint:motionPoint.
- containsPoint ifTrue:[ item := self itemAtPoint:motionPoint ].
+ containsPoint := self containsPoint:motionPoint.
+ containsPoint ifTrue:[
+ item := self itemAtPoint:motionPoint
+ ].
"no aotoscroll, if the mouse pointer is inside the scroll button"
direction := self scrollerDirectionAtPoint:motionPoint.
@@ -3343,7 +3368,7 @@
handleButtonPress:button atPoint:aPoint
"a button pressed; open or close the corresponding submenus"
- | item direction wasSelected|
+ |item scrollerDirectionOrNil wasSelected|
item := self itemAtPoint:aPoint.
item isNil ifTrue:[
@@ -3351,14 +3376,16 @@
^ self
].
- direction := self scrollerDirectionAtPoint:aPoint.
- direction notNil ifTrue:[
- (self scrollActivity startIfRequiredAt:direction on:self comesViaButtonPress:true) ifTrue:[
+ "/ is a scroller-button present and hit ?
+ scrollerDirectionOrNil := self scrollerDirectionAtPoint:aPoint.
+ scrollerDirectionOrNil notNil ifTrue:[
+ (self scrollActivity startIfRequiredAt:scrollerDirectionOrNil on:self comesViaButtonPress:true) ifTrue:[
self pointerEntersItem:nil.
^ self
]
].
+ "/ right button always immediately pulls the delayedMenu
button == 2 ifTrue:[
item hasDelayedMenu ifTrue:[
self selection:item openMenu:false.
@@ -3371,7 +3398,15 @@
wasSelected ifFalse:[
self selection:item openMenu:true
].
- item hasDelayedMenu ifTrue:[^ self].
+ item hasDelayedMenu ifTrue:[
+ "/ clicked on the arrow icon ?
+ (item menuIndicatorContains:aPoint) ifTrue:[
+ self selection:item openMenu:false.
+ self openDelayed:item afterSeconds:0.
+ ^ self.
+ ].
+ ^ self
+ ].
(item isToggle or:[item triggerOnDown]) ifFalse:[
(wasSelected and:[item hasSubmenu and:[item visibleSubmenu isNil]]) ifTrue:[
@@ -5208,17 +5243,17 @@
].
selection isNil ifTrue:[^ self].
- selection == enteredItem ifTrue:[
- enteredItem := nil
- ] ifFalse:[
- self pointerEntersItem:nil
- ].
+"/ selection == enteredItem ifTrue:[
+"/ enteredItem := nil
+"/ ] ifFalse:[
+"/ self pointerEntersItem:nil
+"/ ].
ActiveHelp isActive ifTrue:[
helpListener := ActiveHelp currentHelpListener.
helpListener initiateHelpFor:self at:nil now:true.
].
shown ifTrue:[
- self rearrangeItems.
+ "/ self rearrangeItems.
openMenu ifFalse:[
selection invalidate.
@@ -6873,23 +6908,23 @@
drawMenuIndicator
"draw a menu indicator if the item has a menu or delayed menu."
- |x y icon bAbsLevel|
-
- self hasDelayedMenuIndicator ifTrue:[
- icon := MenuPanel delayedMenuIndicator.
- ] ifFalse:[
- self hasMenuIndicator ifTrue:[
- icon := MenuPanel menuIndicator.
- ] ifFalse:[
- ^ self
- ]
+ |x y icon bAbsLevel verticalPosition|
+
+ icon := self menuIndicatorIcon.
+ icon isNil ifTrue:[
+ ^ self
].
x := layout right - icon width.
- false "delayedMenuIndicatorVerticalPosition == #center" ifTrue:[
- y := layout height - icon height // 2 + layout top.
+ verticalPosition := menuPanel menuIndicatorVerticalPosition.
+ verticalPosition == #center ifTrue:[
+ y := (layout height - icon height) // 2 + layout top.
] ifFalse:[
- y := layout bottom - icon height - 2.
+ verticalPosition == #top ifTrue:[
+ y := layout top + 2.
+ ] ifFalse:[
+ y := layout bottom - icon height - 2.
+ ]
].
bAbsLevel := 0.
@@ -6909,7 +6944,9 @@
].
icon displayOn:menuPanel x:x y:y.
- (false "drawDelayedMenuIndicatorSeparator" and:[ menuPanel buttonPassiveLevel ~~ 0 ])
+ (menuPanel drawMenuIndicatorSeparatorLine
+ and:[ self isEntered
+ and:[ menuPanel buttonEnteredLevel ~~ 0] ])
ifTrue:[
menuPanel paint:menuPanel buttonShadowColor.
menuPanel displayLineFromX:x-2 y:layout top+bAbsLevel+1 toX:x-2 y:layout bottom-bAbsLevel-2.
@@ -7092,6 +7129,18 @@
(displayLabel notNil and:[menuPanel notNil]) ifTrue:[
menuPanel invalidateItem:self repairNow:false
]
+!
+
+menuIndicatorIcon
+ "return a menu indicator icon used if the item has a menu or delayed menu."
+
+ self hasDelayedMenuIndicator ifTrue:[
+ ^ MenuPanel delayedMenuIndicator.
+ ].
+ self hasMenuIndicator ifTrue:[
+ ^ MenuPanel menuIndicator.
+ ].
+ ^ nil
! !
!MenuPanel::Item methodsFor:'initialization'!
@@ -7725,6 +7774,23 @@
"Modified: / 5.10.1998 / 12:12:04 / cg"
!
+menuIndicatorContains:aPoint
+ "returns true if the items delayed menu is hit by a button-press"
+
+ |icon xSep|
+
+ (self isVisible and:[layout notNil]) ifTrue:[
+ (layout containsPoint:aPoint) ifTrue:[
+ icon := self menuIndicatorIcon.
+ icon notNil ifTrue:[
+ xSep := layout right - icon width.
+ ^ aPoint x >= xSep
+ ]
+ ]
+ ].
+ ^ false
+!
+
needsItemSpaceWhenDrawing
^ self isSeparator not and:[menuItem isButton not]
!
@@ -7986,7 +8052,7 @@
!MenuPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.465 2008-05-19 13:39:11 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.466 2008-05-23 13:03:41 cg Exp $'
! !
MenuPanel initialize!