On Tuesday, April 22, 2003, at 07:12 PM, mckernon wrote: > I'm tending to some of the remaining items on my to-do list, and one of > them is letting users use their mouse wheel to scoll up and down on > various part of Lightwright. I seem to recall that the Mac OS used to > handle this automatically, but if it used to, it doesn't now. > > Any suggestions how I go about connecting vertical scroll bars with the > mouse wheel? (Both OS9 and OSX). > Dr. Purves offered (on 23 Feb 03) the following (which certainly works in X): There is no direct support in MacOS 8/9 for mouse wheels. An extension provided by the mouse vendor converts wheel changes into simulated mouse clicks in the up/down parts of a scroll bar. In OS X you can try something like the example below. I can't test this because I don't have a mouse with a wheel. CarbonEvent handlers are simple to write and install; the demo may just work anyway :-) '-------------- '~'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 Feb 2003 */ include "Tlbx CarbonEvents.Incl" end globals local fn InstallMouseWheelHandler( w as WindowRef ) '~'1 dim as EventTypeSpec mouseEvents begin globals dim as proc sMouseWheelEventUPP // 'static' var end globals long if ( sMouseWheelEventUPP == _nil ) sMouseWheelEventUPP = fn NewEventHandlerUPP( [Proc "MouseWheelHandler" ¬ + _FBprocToProcPtrOffset] ) end if mouseEvents.eventClass = _kEventClassMouse mouseEvents.eventKind = _kEventMouseWheelMoved end fn = fn InstallEventHandler( fn GetWindowEventTarget( w ), ¬ sMouseWheelEventUPP, 1, @mouseEvents, #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 EventMouseWheelAxis @ axis dim as long @ delta ignore = fn GetEventParameter( theEvent, _kEventParamMouseWheelAxis, ¬ _typeMouseWheelAxis, #0, sizeof( axis ), #0, @axis ) ignore = fn GetEventParameter( theEvent, _kEventParamMouseWheelDelta, ¬ _typeLongInteger, #0, sizeof( long ), #0, @delta ) print "Wheel axis: " axis " Delta: " delta" exitproc = _noErr // we handled end if // Main program '~'1 long if ( system( _sysVers ) < 1000 ) shutdown "Requires OS X" end if window 1 fn InstallMouseWheelHandler( window( _wndRef ) ) do HandleEvents until 0 '-------------- Robert P. -- Ted Spencer -- Nature, you see, is very difficult to rehearse, and nature has a bad trick of missing its cues. (Robertson Davies)