[futurebasic] Re: [FB] Beginner: Mouse function

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2010 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 3 Feb 2010 09:57:32 -0500
Emmett asked:

>In the "Very Simple Carbon Events Mouse Tracking Demo".
>Is it possible to remove the blinking and place x and y on separate
>lines?
>I have done that but cannot get x to print 0 blank blank. Instead it
>prints 000. The y line prints perfect.

Emmett,

Try this.

Ken

/*
     Very Simple Carbon Events Mouse Tracking Demo
     Version 2
     Ken Shmidheiser
     February 3, 2010
*/

include "Util_CE.incl"

local fn MyMouseTrackingHandler( nextHandler as EventHandlerCallRef, 
theEvent as EventRef, userData as pointer )
'~'1
dim as OSStatus result   : result = _eventNotHandledErr
dim as OSStatus err
dim as Point    xy
dim as Str63    s
dim as MouseTrackingResult mouseStatus
dim as UInt32   eventClass : eventClass = fn GetEventClass( theEvent )
dim as UInt32   eventKind  : eventKind  = fn GetEventKind( theEvent )

select ( eventClass )
case _kEventClassMouse
select ( eventKind )
case _kEventMouseMoved
err = fn GetEventParameter(  theEvent, _kEventParamMouseLocation, 
_typeHIPoint, #0, SizeOf( point ), #0, xy )
err = fn TrackMouseLocation( 0, xy, mouseStatus )
s  = "x axis = " + Str$( xy.h ) + Chr$(13)
s += "y axis = " + Str$( xy.v )
end select
end select

fn SetButtonTextString( 1, s )

end fn

local fn BuildCEWindow
'~'1
dim as Rect r
dim as ControlFontStyleRec tfs

SetRect( r, 0, 0, 500, 350 )
appearance window 1, "CE Mouse Tracker", @r, _kDocumentWindowClass, 
_kWindowStandardHandlerAttribute
text _geneva, 14
SetRect( r, 20, 10, 480, 50 )
appearance button 1,,,,,, @r, _kControlStaticTextProc
tfs.flags = _kControlUseJustMask
tfs.just = _teJustCenter
fn SetButtonFontStyle( 1, tfs )
fn SetButtonTextString( 1, "Move mouse cursor in window" )

fn CEAddEvent( _kEventClassMouse, _kEventMouseMoved )
fn CEInstallWindowEventHandler( window(_wndRef), @fn 
MyMouseTrackingHandler, 0, 0 )

end fn

fn BuildCEWindow

RunApplicationEventLoop()