--- a/DisplayObject.st Sat Jun 01 17:06:03 1996 +0200
+++ b/DisplayObject.st Wed Jun 05 16:00:20 1996 +0200
@@ -328,6 +328,45 @@
^ frame containsPoint: aPoint
!
+frameIsHitBy:aPoint withDelta:delta
+ "return true, if my frame is hit by aPoint"
+
+ |org left right top bott px py d2|
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ (delta == 0) ifTrue:[
+ ^ frame containsPoint:aPoint
+ ].
+
+ "
+ its quicker to not create a new rectangle for the test
+ (which is not obvious for simple lines, but complex polygons
+ or grouped objects may call this for many of its components)
+ "
+ org := frame origin.
+ left := org x - delta.
+
+ px := aPoint x.
+ (px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge"
+
+ d2 := delta * 2.
+ right := left + frame width + d2.
+ (px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge"
+
+ top := org y - delta.
+ py := aPoint y.
+ (py < top) ifTrue:[^ false]. "aPoint is above my top edge"
+
+ bott := top + frame height + d2.
+ (py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge"
+
+ ^ true
+
+ "Created: 5.6.1996 / 15:26:51 / cg"
+!
+
handlesKeyboardInput
"return true, if the receiver handles keyboard input"
@@ -365,38 +404,9 @@
usually this method is redefined in subclasses for a more complete
check (i.e. if objects boundary is not rectangular)"
- |org left right top bott px py d2|
-
- frame isNil ifTrue:[
- frame := self computeBoundingBox
- ].
- (delta == 0) ifTrue:[
- ^ frame containsPoint:aPoint
- ].
+ ^ self frameIsHitBy:aPoint withDelta:delta
- "
- its quicker to not create a new rectangle for the test
- (which is not obvious for simple lines, but complex polygons
- or grouped objects may call this for many of its components)
- "
- org := frame origin.
- left := org x - delta.
-
- px := aPoint x.
- (px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge"
-
- d2 := delta * 2.
- right := left + frame width + d2.
- (px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge"
-
- top := org y - delta.
- py := aPoint y.
- (py < top) ifTrue:[^ false]. "aPoint is above my top edge"
-
- bott := top + frame height + d2.
- (py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge"
-
- ^ true
+ "Modified: 5.6.1996 / 15:27:06 / cg"
!
isOpaque
@@ -422,5 +432,5 @@
!DisplayObject class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.19 1996-05-12 18:41:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.20 1996-06-05 14:00:20 cg Exp $'
! !