Dear all Is there a good way to make a textbox that receive numeric only? something that limit the key it respond to or give sign (like red background or something) if the input is not numeric I wonder if validator can be used for that purpose an example would be very good :) btw is there a datepicker on windows? Thank you Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
No reply after 2 days? thats rare I would like to believe that some of you guys should already did this before and I expect to get some suggestion of course I can simply add value_change event and check if corresponding value is numeric or not but perhaps some of you guys have better ideas? On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma <penguinroad at gmail.com> wrote:> Dear all > > Is there a good way to make a textbox that receive numeric only? > something that limit the key it respond to > or give sign (like red background or something) if the input is not > numeric > > I wonder if validator can be used for that purpose > > an example would be very good :) > > btw > is there a datepicker on windows? > > Thank you > Regards > Hendra > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091211/299a5f28/attachment.html>
Set the textfied validator to this: your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) cheers. bio. On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma <penguinroad at gmail.com>wrote:> No reply after 2 days? > thats rare > > I would like to believe that some of you guys should > already did this before > and I expect to get some suggestion > > of course I can simply add value_change event > and check if corresponding value is numeric or not > but perhaps some of you guys have better ideas? > > > On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma <penguinroad at gmail.com>wrote: > >> Dear all >> >> Is there a good way to make a textbox that receive numeric only? >> something that limit the key it respond to >> or give sign (like red background or something) if the input is not >> numeric >> >> I wonder if validator can be used for that purpose >> >> an example would be very good :) >> >> btw >> is there a datepicker on windows? >> >> Thank you >> Regards >> Hendra >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> > > > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091211/3d08277d/attachment-0001.html>
Thanks, I''ll try it On Fri, Dec 11, 2009 at 8:31 PM, Fabio Petrucci <fabio.petrucci at gmail.com>wrote:> Set the textfied validator to this: > > your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) > > cheers. > > bio. > > > On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma <penguinroad at gmail.com>wrote: > >> No reply after 2 days? >> thats rare >> >> I would like to believe that some of you guys should >> already did this before >> and I expect to get some suggestion >> >> of course I can simply add value_change event >> and check if corresponding value is numeric or not >> but perhaps some of you guys have better ideas? >> >> >> On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma <penguinroad at gmail.com>wrote: >> >>> Dear all >>> >>> Is there a good way to make a textbox that receive numeric only? >>> something that limit the key it respond to >>> or give sign (like red background or something) if the input is not >>> numeric >>> >>> I wonder if validator can be used for that purpose >>> >>> an example would be very good :) >>> >>> btw >>> is there a datepicker on windows? >>> >>> Thank you >>> Regards >>> Hendra >>> -- >>> Suka linux? >>> Kunjungi blog saya http://penguinroad.blogspot.com >>> >> >> >> >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091212/620cdd8d/attachment.html>
Bad idea with this validator I can type 954.564.546..123eee23 that would not be valid number, right? On Sat, Dec 12, 2009 at 8:59 AM, hendra kusuma <penguinroad at gmail.com>wrote:> Thanks, I''ll try it > > > On Fri, Dec 11, 2009 at 8:31 PM, Fabio Petrucci <fabio.petrucci at gmail.com>wrote: > >> Set the textfied validator to this: >> >> your_text_field.validator = Wx::TextValidator.new(Wx::FILTER_NUMERIC) >> >> cheers. >> >> bio. >> >> >> On Fri, Dec 11, 2009 at 10:03 AM, hendra kusuma <penguinroad at gmail.com>wrote: >> >>> No reply after 2 days? >>> thats rare >>> >>> I would like to believe that some of you guys should >>> already did this before >>> and I expect to get some suggestion >>> >>> of course I can simply add value_change event >>> and check if corresponding value is numeric or not >>> but perhaps some of you guys have better ideas? >>> >>> >>> On Wed, Dec 9, 2009 at 9:51 AM, hendra kusuma <penguinroad at gmail.com>wrote: >>> >>>> Dear all >>>> >>>> Is there a good way to make a textbox that receive numeric only? >>>> something that limit the key it respond to >>>> or give sign (like red background or something) if the input is not >>>> numeric >>>> >>>> I wonder if validator can be used for that purpose >>>> >>>> an example would be very good :) >>>> >>>> btw >>>> is there a datepicker on windows? >>>> >>>> Thank you >>>> Regards >>>> Hendra >>>> -- >>>> Suka linux? >>>> Kunjungi blog saya http://penguinroad.blogspot.com >>>> >>> >>> >>> >>> -- >>> Suka linux? >>> Kunjungi blog saya http://penguinroad.blogspot.com >>> >>> _______________________________________________ >>> wxruby-users mailing list >>> wxruby-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/wxruby-users >>> >> >> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> > > > > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091212/d1d4fd54/attachment-0001.html>
hendra kusuma wrote:> Bad idea > with this validator > I can type 954.564.546..123eee23 > that would not be valid number, right?I think the validators only work by filtering characters - all of those characters (including e, for scientific notation) are potentially part of a valid number. But it won''t test if the whole string is a valid number. If you need that level of sophisticated filtering, you could add an event handler to the textctrl which checks in Ruby that the string can be validly converted to a number. Something like (untested) evt_text(my_textctrl) do | e | begin num = Float(my_textctrl.value) rescue ArgumentError puts ''sorry that''s a valid string'' end end a
On Tue, Dec 15, 2009 at 3:56 AM, Alex Fenton <alex at pressure.to> wrote:> hendra kusuma wrote: > >> Bad idea >> with this validator I can type 954.564.546..123eee23 >> that would not be valid number, right? >> > > I think the validators only work by filtering characters - all of those > characters (including e, for scientific notation) are potentially part of a > valid number. But it won''t test if the whole string is a valid number. > > If you need that level of sophisticated filtering, you could add an event > handler to the textctrl which checks in Ruby that the string can be validly > converted to a number. Something like (untested) > > evt_text(my_textctrl) do | e | > begin > num = Float(my_textctrl.value) > rescue ArgumentError > puts ''sorry that''s a valid string'' > end > end > >Yes, this is exactly what I think at first I just want to know if there is a build in library for that purpose Thanks anyway -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091215/2133c73e/attachment-0001.html>