extracted common code to detectViewAt:aPoint.
use new translatePoint:fromView:toView:
--- a/MenuPanel.st Wed Oct 10 15:07:30 2001 +0200
+++ b/MenuPanel.st Wed Oct 10 15:08:33 2001 +0200
@@ -2841,7 +2841,7 @@
implicitGrabView notNil ifTrue:[
ev isButtonEvent ifTrue:[
- p := device translatePoint:(x@y) from:(self id) to:(implicitGrabView id).
+ p := device translatePoint:(x@y) fromView:self toView:implicitGrabView.
ev view:implicitGrabView.
ev arguments at:2 put:p x.
ev arguments at:3 put:p y.
@@ -2862,7 +2862,7 @@
p := menu translateGrabPoint:(x@y).
view := self detectViewAtX:(p x) y:(p y) in:menu.
- p := device translatePoint:(x@y) from:(self id) to:(view id).
+ p := device translatePoint:(x@y) fromView:self toView:view.
ev isButtonPressEvent ifTrue:[
(view wantsFocusWithButtonPress) ifTrue:[
@@ -2899,6 +2899,8 @@
ev x:p x.
ev y:p y.
view dispatchEvent:ev withFocusOn:focusView delegate:false.
+
+ "Modified: / 10.10.2001 / 13:54:47 / cg"
!
handleButtonMotion:state x:x y:y
@@ -4337,21 +4339,27 @@
detectViewAtX:x y:y in:aTopView
"detect view at x@y
"
- |p subViews|
-
- (subViews := aTopView subViews) notNil ifTrue:[
- subViews do:[:v| |p|
- v shown ifTrue:[
- ( (x between:(v left) and:(v right))
- and:[y between:(v top) and:(v bottom)]
- ) ifTrue:[
- p := device translatePoint:(x@y) from:(aTopView id) to:(v id).
- ^ self detectViewAtX:p x y:p y in:v.
- ]
- ]
- ]
- ].
- ^ aTopView
+ ^ aTopView detectViewAt:(x@y).
+
+"/ cg: old code was (refactored to use common code)
+"/
+"/ |p subViews|
+"/
+"/ (subViews := aTopView subViews) notNil ifTrue:[
+"/ subViews do:[:v| |p|
+"/ v shown ifTrue:[
+"/ ( (x between:(v left) and:(v right))
+"/ and:[y between:(v top) and:(v bottom)]
+"/ ) ifTrue:[
+"/ p := device translatePoint:(x@y) from:(aTopView id) to:(v id).
+"/ ^ self detectViewAtX:p x y:p y in:v.
+"/ ]
+"/ ]
+"/ ]
+"/ ].
+"/ ^ aTopView
+
+ "Modified: / 10.10.2001 / 13:45:56 / cg"
!
itemAtX:x y:y
@@ -4587,22 +4595,16 @@
!
-translatePoint:aPoint to:aWindow2
- "translate a point in my window to the point in aWindow2 (or root window if nil)
- "
- |id sX sY|
-
- aPoint isNumber ifTrue:[
- sX := sY := aPoint .
- ] ifFalse:[
- sX := aPoint x.
- sY := aPoint y.
- ].
-
- aWindow2 isNil ifTrue:[ id := device rootWindowId ]
- ifFalse:[ id := aWindow2 id ].
-
- ^ device translatePoint:(sX@sY) from:drawableId to:id
+translatePoint:aPoint to:anotherWindowOrNilForScreen
+ "translate a point in my window to anotherWindowOrNilForScreen (or root window if nil)
+ "
+
+ ^ device
+ translatePoint:aPoint asPoint
+ fromView:self
+ toView:anotherWindowOrNilForScreen
+
+ "Modified: / 10.10.2001 / 14:11:47 / cg"
! !
!MenuPanel::Item class methodsFor:'accessing'!
@@ -6820,6 +6822,6 @@
!MenuPanel class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.276 2001-10-10 06:43:34 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.277 2001-10-10 13:08:33 cg Exp $'
! !
MenuPanel initialize!