[BUG] cursor position not correct for events when mouse outside S queak window

Joerg Beekmann beekmann at columbusgroup.com
Fri Feb 16 17:10:06 UTC 2001


Squeak3.1alpha Image from 13 February 2001 latest update: #3602
Squeak 3.0 VM (alpha build 3) from Feb 8 2001

If the "Squeak" flap on the left is extended to the left of the Squeak
window itself the flap jumps to extend all the way to the right and beyond.
In a similar way if the "Tools" flap is extended to the left of the border
of the Squeak window the flap jumps back to the closed position.

Both of these effects seem to be due to the fact that the x value of the
mouse event is reported as (65536 - distance to the left of the window
border) once the mouse moves left of the window border while dragging. The
same seems to apply to the y axis. To see this change the definition of
processEvent: as follows:

EventSensor>>processEvent: evt
   (evt at: 3) > 65000 | ((evt at: 3) < 5)
      ifTrue: [Transcript cr; show: thisContext method selector , '::' ,
(evt at: 3) printString].
    ... rest of method

Note the value in the transcript drop to zero and then jump to > 65000 as
the cursor moves left out of the Squeak window. I think this is an error in
<primative 94> but I couldn't figure out how the primatives are defined. Is
each primative defined by a respective primativeXxxx method in Interpreter?
There was nothing in Interpreter>>primitiveGetNextEvent that seemed wrong to
me. But then I don't understand how the transaltion to C is effected. I also
don't understand why no events are created when the mouse is moved without
dragging but that is another discussion. Is all this explained anywhere?

Anyway a quick fix to the problem of the flaps jumping about this is the
following update to FlapTab>>mouseMove:. Not pretty and really the event
stuff should be fixed. 

mouseMove: evt 
 | aPosition newReferentThickness adjustedPosition thick x y |
 dragged
  ifFalse: [(thick _ self referentThickness) > 0
    ifTrue: [lastReferentThickness _ thick]].

 "Ugh - deal with bug in event generation which results in x & y values over
  65536 when for postions left and above the Squeak window."
 x _ evt cursorPoint x.
 y _ evt cursorPoint y.
 x > 60000 ifTrue: [x _ 0]. "60000 should mask the problem most of the time"
 y > 60000 ifTrue: [y _ 0].
 aPosition _ x at y.

 ((self containsPoint: aPosition)
   and: [dragged not])
  ifFalse: [flapShowing
    ifFalse: [self showFlap].
   adjustedPosition _ aPosition - evt hand targetOffset.
   edgeToAdhereTo == #bottom
    ifTrue: [newReferentThickness _ inboard
        ifTrue: [self world height - adjustedPosition y]
        ifFalse: [self world height - adjustedPosition y - self height]].
   edgeToAdhereTo == #left
    ifTrue: [newReferentThickness _ inboard
        ifTrue: [adjustedPosition x + self width]
        ifFalse: [adjustedPosition x]].
   edgeToAdhereTo == #right
    ifTrue: [newReferentThickness _ inboard
        ifTrue: [self world width - adjustedPosition x]
        ifFalse: [self world width - adjustedPosition x - self width]].
   edgeToAdhereTo == #top
    ifTrue: [newReferentThickness _ inboard
        ifTrue: [adjustedPosition y + self height]
        ifFalse: [adjustedPosition y]].
   self isCurrentlySolid
    ifFalse: [(#(#left #right ) includes: edgeToAdhereTo)
      ifTrue: [self top: adjustedPosition y]
      ifFalse: [self left: adjustedPosition x]].
   self applyThickness: newReferentThickness.
   dragged _ true.
   self fitOnScreen]

-----------------------------------------------------
Joerg Beekmann
jbeekmann at equinix.com
t: 650.316.6119

beekmann at columbusgroup.com
www.columbusgroup.com
t: 604 801 5758  ext. 300
c: 604 512 2557
Vancouver + Toronto + Seattle





More information about the Squeak-dev mailing list