[futurebasic] Re: [FB] scroll buttons

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2006 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sat, 30 Sep 2006 08:38:30 -0700
On Sep 30, 2006, at 5:18 AM, Douglas Stemen wrote:

> Can someone provide sample code or point me to an FB example on the  
> disk that explains how to detect use of scroll wheels or scrolling  
> track pads to control scroll buttons in my programs?
This is in my Donations folder (Robert P Favorites sub-folder) . I  
also have a full project demo project I can send backchannel if you  
need it.

Brian S.




'~'A
'                       Runtime : Rntm Appearance.Incl
'                           CPU : Carbon
'~'B

/*
Simple detection of mouse wheel events in OS X.
A CarbonEvent handler for
{_kEventClassMouse, _kEventMouseWheelMoved}
is installed on the window.
Robert P.    23 June 2004
*/

include "Tlbx CarbonEvents.Incl"
end globals

local fn InstallMouseWheelHandler
'~'1
dim as EventTypeSpec  events
begin globals
dim as proc  sMouseWheelEventUPP // 'static' var
end globals

long if ( sMouseWheelEventUPP == _nil )
    sMouseWheelEventUPP = fn NewEventHandlerUPP( [Proc  
"MouseWheelHandler" ¬
    + _FBprocToProcPtrOffset] )
end if
events.eventClass = _kEventClassMouse
events.eventKind  = _kEventMouseWheelMoved

end fn = fn InstallEventHandler( fn GetApplicationEventTarget(), ¬
      sMouseWheelEventUPP, 1, @events, #0, #0 )


long if 0
"MouseWheelHandler"
enterproc fn MouseWheelHandler( nextHandler as EventHandlerCallRef, ¬
   theEvent as EventRef, userData as Ptr ) = OSStatus
'~'1
dim as OSStatus                ignore
dim as long                    wNum, wOldOut
dim as WindowRef             @ w
dim as EventMouseWheelAxis   @ axis
dim as long                  @ delta

ignore = fn GetEventParameter( theEvent, _kEventParamWindowRef, ¬
    _typeWindowRef, #0, sizeof( WindowRef ), #0, @w )

ignore = fn GetEventParameter( theEvent, _kEventParamMouseWheelAxis, ¬
    _typeMouseWheelAxis, #0, sizeof( axis ), #0, @axis )

ignore = fn GetEventParameter( theEvent, _kEventParamMouseWheelDelta, ¬
    _typeLongInteger, #0, sizeof( long ), #0, @delta )


wNum = fn FBGetWndNumber( w )
long if ( wNum )
wOldOut = window( _outputWnd )
window output wNum
print "Wheel axis: " axis  "  Delta: " delta"
window output wOldOut
end if

exitproc = _noErr // we handled
end if


// Main program
'~'1
long if ( system( _sysVers ) < 1000 )
shutdown "Requires OS X"
end if

window 1

fn InstallMouseWheelHandler

do
HandleEvents
until 0