Slider&TextField

BlitzMax Forums/MaxGUI Module/Slider&TextField

degac(Posted 2007) [#1]
I have a little problem and maybe someone can point me in the right direction.
Global win:TGadget=CreateWindow("test",50,50,286,154,0,9)
Global tb:TGadget=CreateSlider(142,60,10,20,win,SLIDER_STEPPER)
SetSliderRange tb,-1000,1000
SetSliderValue tb,0

Global text:tgadget = CreateTextField(40 , 60 , 100 , 20 , win)


Repeat
	Select WaitEvent()
		Case EVENT_GADGETACTION
			Select EventSource()
				Case tb
				SetStatusText win , Float(EventData() ) / 100.0
				SetGadgetText text, Float(EventData() ) / 100.0

				Case text
				SetStatusText win, "Slider: "+Float(EventData())/100+" New: "+GadgetText(text).tofloat()
				SetSliderValue tb , GadgetText(text).tofloat()*100
				RedrawGadget tb
			End Select
		Case EVENT_WINDOWCLOSE
			Exit
	End Select
Forever
End


Basically I want that when the user press the stepper the value is shown in the textfield - and THIS works ok.
But I want too that when the user types in textfield a new value the Stepper will change its own 'position'...and this is the problem!
Second problem: type 0 in the textfield, then press the stepper DOWN, you will see a value starting from 655.349976 and so on...a little different from what I want.
My question is: there are limit in the SetSliderRange value?

Byez


jsp(Posted 2007) [#2]
Something like this?

Global win:TGadget=CreateWindow("test",50,50,286,154,0,9)
Global tb:TGadget=CreateSlider(142,60,10,20,win,SLIDER_STEPPER)
SetSliderRange tb,0,2000
SetSliderValue tb,1000

Global text:tgadget = CreateTextField(40 , 60 , 100 , 20 , win)


Repeat
	Select WaitEvent()
		Case EVENT_GADGETACTION
			Select EventSource()
				Case tb
				SetStatusText win , (Float(EventData() ) )-1000
				SetGadgetText text, (Float(EventData() ) )-1000

				Case text
				SetStatusText win, "Slider: "+((Float(EventData() ))-1000)+" New: "+(GadgetText(text).tofloat()-1000)
				SetSliderValue tb , GadgetText(text).tofloat()+1000
			End Select
		Case EVENT_WINDOWCLOSE
			Exit
	End Select
Forever
End



degac(Posted 2007) [#3]
So the range for Slider should be between 0..N and I need to scale the result properly.
Thanks


jsp(Posted 2007) [#4]
Not all slider types, as far as i remember correctly minus values are working fine with a trackbar ...