[futurebasic] slider suggestions solicited

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

From: "Edwards, Waverly" <Waverly.Edwards@...>
Date: Sun, 27 Sep 2009 17:55:25 -0500
I have a problem that I dont have a good solution for.  I have a slider that I want to perform an action.
Once the  user is no longer has the mouse down in slider, I want an action to be performed.
The only way I can think to make it work is to install a timer proc and check that checks to see if the
mouse is up.  If the mouse is up, perform the action and remove the timer.  I am currently performing 
actions based on the live slider value but  The action I need to perform is CPU intensive and *only* 
needs to be performed once the user has finished with the slider.

If anyone has ideas on how I could better handle this I would be glad to hear from them.
I believe the below sketch could be done, ( I havent implemented it yet ) but I suspect there
is a better way to get the job done.


Thank you for any ideas you may have,


W.


// sketch of what I believe would work

local fn SliderTimerProc( inTimer as EventLoopTimerRef, inUserData as ptr to userData )
'~'1

long if (  fn button == _false )
// perform CPU intensive action and remove timer
end if

end fn



local fn ScaleSliderAction( c as ControlRef, partCode as short )
'~'1

dim as SInt32      currValue
dim as OSErr       err

currValue = fn GetControl32BitValue ( c )
/ * do something here when the user moves the thumb of the slider */

err  = fn InstallEventLoopTimer( fn GetCurrentEventLoop( ) , 0, kFireFrequency, @fn SliderTimerProc , #thisData, @caretTimerRef )

beep
end fn


local fn InstallMySliderAction( c as ControlRef )
'~'1
SetControlAction( c, @fn ScaleSliderAction )
end fn

fn InstallMySliderAction( button&( _sliderScaleBtn ) )