Slidy Sliders - help please (skid?)

BlitzMax Forums/BlitzMax GUI Programming/Slidy Sliders - help please (skid?)

Two words - event hooks! ;-)

The basic idea is that the scrollbar generates events as you move the knob, but they are only added to the Blitz Event Queue after you release. To make matters worse, the action causes the program to go into a modal loop, one which is not left until you release the mouse button, at which point the program is allowed to carry on with its processing. If you want to catch all the events (as they happen) you need to use an Event Hook - which basically involves adding your own function to the internal Blitz list that Blitz calls when it catches an event.

SuperStrict

Global win:TGadget = CreateWindow("test" , 0 , 0 , 200 , 200 , Null , WINDOW_TITLEBAR) 
Global tab:TGadget = CreateTabber(0 , 0 , 150 , 150 , win)
Global panel:TGadget = CreatePanel(0 , 0 , 130 , 500 , tab)
Global slider_v:TGadget = CreateSlider(ClientWidth(tab) - 20 , 0 , 20 , ClientHeight(tab) , tab)
SetSliderRange slider_v , ClientHeight(tab) , 500

For Local i:Int = 0 To 20
	CreateButton "test " + i , 10 , 10 + i * 20 , 110 , 15 , panel
Next

Global t:TTimer = CreateTimer(60)

AddHook EmitEventHook, eventHook

Repeat
	WaitSystem
Forever


Function eventHook:Object(pID%, pData:Object, pContext:Object)

	Local pEvent:TEvent = TEvent(pData)
	If Not pEvent Then Return pData
	
	Select pEvent.source 
		Case win
			If pEvent.id = EVENT_WINDOWCLOSE Then End
		Case slider_v
			If pEvent.id = EVENT_GADGETACTION Then
				SetGadgetShape panel,0,-pEvent.data,GadgetWidth(panel),GadgetHeight(panel)
			EndIf
		Case t
			SetGadgetShape panel,0,-SliderValue(slider_v),GadgetWidth(panel),GadgetHeight(panel)
	EndSelect

EndFunction


Quick example for you that should hopefully show you what I mean. Check out Assari's EventHook MaxGUI Tutorial for more information.