Page 1 of 1

StringGadget : #PB_String_Numeric

Posted: Mon Sep 05, 2005 4:00 pm
by Flype
just a little but annoying bug ( or inappropriate behavior )
just test the snippet below :

Code: Select all

;- A sort of bug with StringGadget & #PB_String_Numeric

If OpenWindow(0,0,0,300,230,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"StringGadget Test")
  
  
  CreateGadgetList(WindowID())
  StringGadget(0,5, 5,290,20,"123.45",#PB_String_Numeric)
  StringGadget(1,5,35,290,20,"#ALPHA*/\",#PB_String_Numeric)
  
  
  Msg$ = "Let's test one thing or two... with PB3.94 Update 1" + Chr(10) + Chr(10)
  Msg$ + "1/ do you think it's normal that a numeric stringgadget accept alpha cars at initialisation ?" + Chr(10) + Chr(10)
  Msg$ + "2/ copy an alpha car from the stringgadget above and 'paste' it to the other : it works but it shoudn't works !" + Chr(10) + Chr(10)
  Msg$ + "A friend makes one of my prog violently crash because of this 'available feature'."
  TextGadget(2,5,65,290,160,Msg$,#PB_Text_Border)
  
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  
  
EndIf

Posted: Mon Sep 05, 2005 4:03 pm
by Lebostein
Why I can't input "." and "-" in a numeric StringGadget(), for example "-123.50"?

Posted: Mon Sep 05, 2005 4:14 pm
by Flype
you can ! by copy-paste from clipboard... :lol:
ok that's not a serious way...

Re: StringGadget : #PB_String_Numeric

Posted: Thu Sep 08, 2005 1:09 pm
by PB
The #PB_String_Numeric flag is just the equivalent of the Microsoft ES_NUMBER
flag, so it behaves the way Microsoft intended. Microsoft's description for this
flag states: Allows only digits to be entered into the edit control. Note that, even
with this set, it is still possible to paste non-digits into the edit control.


(Taken from: http://tinyurl.com/9bl7m ).

> do you think it's normal that a numeric stringgadget accept alpha cars at initialisation ?

As per the above, yes, it's normal -- it only stops TYPED (ie. "entered") characters,
and only allows digits (ie. 0-9) and nothing else to be typed (ie. - and . etc).

> copy an alpha car from the stringgadget above and 'paste' it to the other
> it works but it shoudn't works

Again, see the description by Microsoft above. :)

Posted: Fri Sep 09, 2005 7:37 am
by Flype
ok PB thanx for the explanation, so i don't agree the Microsoft way...
:wink: