Forum: wxRuby numeric textbox

Posted by hendra kusuma (Guest)
on 2010-04-06 11:14
(Received via mailing list)
Dear all,

what is a good way to implement a textbox that can only receive number?
when I tried to implement it using text_updated event
it runs so slow that it disturb overall process (my menu stop working)
or even better, what method to overwrite in wxtextctrl class to achieve 
the
goal?

Regards
Hendra
Posted by Alex Fenton (Guest)
on 2010-04-06 13:05
(Received via mailing list)
Hi Hendra

hendra kusuma wrote:
> what is a good way to implement a textbox that can only receive number?

The best way is to use Validators. There's a pre-built one for
controlling numerics:

Wx::TextCtrl.new(parent,
  :validator => Wx::TextValidator.new(Wx::FILTER_NUMERIC) )

cheers
alex
Posted by hendra kusuma (Guest)
on 2010-04-07 05:52
(Received via mailing list)
On Tue, Apr 6, 2010 at 6:04 PM, Alex Fenton <alex@pressure.to> wrote:

>
> Wx::TextCtrl.new(parent,
>  :validator => Wx::TextValidator.new(Wx::FILTER_NUMERIC) )
>

I tried filter_numeric before
and found out if it only filter input, not realy confirm if the number
correct
I try to workaround a bit using key_update event
and filter some more key like + - , . e
well, it works well, the trick is to use* change_value*, not *set_value*
somehow, when I try to add humanizing number function, I got stuck
(humanizing = 10000 -> 10,000)
because I cannot move my cursor / insert point to the last of textctrl
and *set_insertion_point_end* does not seem to work
is there a way to fix this?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.