Page 1 of 1

NumberGadget(GID,X,Y,W,H,MINVALUE,MAXVALUE,TYPE)

Posted: Thu Sep 02, 2004 12:57 pm
by naw
This would be very nice and save (me) countless lines of correction code.

NumberGadget(123,x,y,w,h,0,100,1) - 0 = Integer 1 = Float

Or Perhaps the functionality could be added as a parameter to TextGadget.
(I think NumberGadget makes more sense though)

What would be really cool, though would be a RegularExpressionGadget ;-)

eg: REGadget(GID,x,y,w,h,"[A-Z][A-Z][0-9]-[0-9][A-Z][A-Z]")

would only allow input of a UK style postcode eg: S43-2BB

NumberGadget will do just fine, though ;-)

Re: NumberGadget(GID,X,Y,W,H,MINVALUE,MAXVALUE,TYPE)

Posted: Thu Sep 02, 2004 1:58 pm
by PB
> the functionality could be added as a parameter to TextGadget

You can specify #PB_String_Numeric with a StringGadget like so:

Code: Select all

OpenWindow(0,200,200,250,100,#PB_Window_SystemMenu,"Numbers only!")
CreateGadgetList(WindowID())
StringGadget(0,10,10,225,20,"",#PB_String_Numeric)
Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow
But this is a bit flawed, in that you can still paste other characters into it. *
Also, you'd have to do your own checking to ensure the number entered
doesn't go outside your min/max range. Still, it's a start. :)

(Edited to mention: * = Flawed by Win32 API, not by PureBasic).

Posted: Fri Sep 03, 2004 12:09 pm
by naw
Thanks PB, #PB_String_Numeric is not in the documentation under TextGadget() its really frustrating when that Fred does all this neat stuff but keeps it secret ;-)

But - it allows only 0123456789.

Sooo, Fred, any chance we could have:

#PB_String_Float to allow - (minus) and . (point) characters

Posted: Fri Sep 03, 2004 12:25 pm
by PB
> #PB_String_Numeric is not in the documentation under TextGadget()

That's because it only applies to StringGadgets, not TextGadgets. ;)
TextGadgets are for displaying text, StringGadgets are for user input.

Posted: Fri Sep 03, 2004 3:56 pm
by naw
Doh!

me too stoopid to be programmer

8O