[futurebasic] suggestions solicited ( event handling )

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2009 : Group Archive : Group : All Groups

From: "Edwards, Waverly" <Waverly.Edwards@...>
Date: Thu, 15 Oct 2009 11:23:16 -0500
Seeking suggestions of how to handle the following scenario:

Note: this is not the actual code but it's a close approximation

I have a kEventControlTrack handler attached to a custom HIView, (not the window or application.
I am tracking the mouse in the HIView.  The mouse is being dragged outside the view.
When this occurs, the mouseLoc information is no longer valid, even though I'm inside the tracking loop.

I want to keep the tracking on the HIView but suspect that I'm not getting the correct mouse location
because my handler is on the HIView.  Any thoughts on how to keep the correct mouse location while inside the loop.
If I use GetMouse, I will consume lots of CPU time when the mouse is not moving some I'm a bit stumped.

The goal is to track the mouse location once I'm inside the loop without consuming lots of CPU time.



case _kEventControlTrack

dim as HIPoint mouseLoc
dim as OSStatus status
dim as MouseTrackingResult mouseStatus
dim as MouseTrackingOptions trackingOptions
dim as Point qdPoint

//... get the window bounds

trackingOptions = _kTrackMouseLocationOptionDontConsumeMouseUp // not sure if this is necessary

status = fn GetEventParameter( inEvent, _kEventParamMouseLocation, _typeHIPoint, _nil , sizeof( HIPoint ), _nil, @mouseLoc )

mouseStatus = _kMouseTrackingMouseDown

while ( mouseStatus != _kMouseTrackingMouseUp )

// a -1 GrafPtr to TrackMouseLocationWithOptions yields global coordinates
status = TrackMouseLocationWithOptions( -1, trackingOptions , duration, qdPoint, _nil, @mouseStatus )                  

// convert to window-relative coordinates
mouseLoc.x = qdPoint.h - qdWindowBounds.left
mouseLoc.y = qdPoint.v - qdWindowBounds.top

// do something with the mouse coordinates and mouseStatus