Spinner proxy gadget...advanced number editor

BlitzMax Forums/MaxGUI Module/Spinner proxy gadget...advanced number editor

JoshK(Posted 2009) [#1]
This is probably one of the nicest pieces of code I have ever written:
http://blitzmax.com/codearcs/codearcs.php?code=2514

Maybe this can go in the official module?


Grisu(Posted 2009) [#2]
Screenshots please... :D


degac(Posted 2009) [#3]
I agree, made it officialy in the Proxygadgets

I've update your code with
- SetColor method
- SetEnable (for enable/disable the gadget)
- fixed SetSpinnerValue (you missed a '_' in the SetValue function)

I've tested on Win32, FLTK (win32 based) and they works as expected (they use 'standard' MaxGUI code, not OS specific calls)



Edit: an a little changes to SetSpinnerRange...not very important, but...

Function SetSpinnerRange(spinner:TSpinner,minimum:Double,maximum:Double,accuracy:Int=1)
	spinner.SetRange_(minimum,maximum,accuracy)
	SetGadgetToolTip spinner.textfield,"Min: "+spinner.FloatToString(Minimum,3)+"~nMax: "+spinner.FloatToString(Maximum,3)
EndFunction


So the user can SEE what is the range...


JoshK(Posted 2009) [#4]
I don't think you should set the tooltip like that. If someone wants a tooltip, they will specify one. Otherwise, you should not guess what the user might want.


Mark Tiffany(Posted 2009) [#5]
Agreed, should at least have a check to make sure it isn't already set as it might be useful if you haven't bothered setting a tooltip...


degac(Posted 2009) [#6]
Ok, this is a possible fix
Method SetToolTip(tt$)
		Local prev$=gettooltip()
		SetGadgetToolTip textfield,tt+"~n"+prev
End Method
	
Method GetToolTip$()
		Return textfield.Gettooltip()
End Method
...
Function SetSpinnerRange(spinner:TSpinner,minimum:Double,maximum:Double,accuracy:Int=1)
	spinner.SetRange_(minimum,maximum,accuracy)
	
	Local prev$=spinner.GetToolTip()
	If prev<>"" prev=prev+"~n"
	
	SetGadgetToolTip spinner.textfield,prev+"Min: "+spinner.FloatToString(Minimum,3)+"~nMax: "+spinner.FloatToString(Maximum,3)
EndFunction

So the user-tooltip is save.
In any case my was only a suggestion: if you have a window full of this controls I think is useful for the user know what he/she's changing..


JoshK(Posted 2009) [#7]
I think if the programmer wants a tooltip they should specify one themselves. You could add a label below the minimum and maximum extents of the track bar.


JoshK(Posted 2009) [#8]
Updated the code.