Numeric textbox

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

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

On Tue, Apr 6, 2010 at 6:04 PM, Alex F. [email protected] 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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs