[wxPython-users] Re: Custom validator

Robin Dunn robin at alldunn.com
Tue Jan 2 12:44:58 PST 2007


Paul Koning wrote:
>>>>>> "Robin" == Robin Dunn <robin at alldunn.com> writes:

> 
> For example, I have a text control where a user is expected to enter a
> number.  The rational behavior is to ignore non-numeric keystrokes,
> and I foolishly expected a validator to be able to do that.  No such
> luck.  But now I know how to get that effect.  Thanks!

The validator can do that, since it gets first crack at the events going 
to the control.  So it can just catch EVT_CHAR and either allow the 
control to get the event (by calling evt.Skip) or block it, (by not 
calling Skip).  This is shown in the demo.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list