From: Mattia B. <mb...@ds...> - 2001-12-17 22:21:13
|
> Dear Mattia (or others, if they can help), > I've been delving into how to use wxValidators, and I think I understand the > concept (and I like it!). > > However, I'm having real trouble deriving my own validator (called, > unimaginitively, myValidator) from Wx::PlValidator. > > >From the wxWindows documentation, all validators must implement a Clone > method. I have tried implementing a Clone method, which I can see getting > called, but myValidator's Validate, TransferFromWindow, and TransferToWindow > never seem to get called. > > Here is my code (with the methods apart from Clone doing nothing useful > apart from printing to STDOUT): > > VVVVVVVVVVVVVVVVVVVV > use Wx; > > package myValidator; This is OK ( in fact the sample I sant uses this code ) > ^^^^^^^^^^^^ > > Could you post a very simple example of how to create a validator class in > Perl, and how to create a frame which uses it, please? Here is your example ( modified minimal sample, use Help->About to show the validator dialog ) I am getting a "Attempt to free unreferenced scalar at C:/Developement/wxPerl/wxPerl/blib/lib/Wx.pm line 61.", which I was not getting when I first tested Validators. It is obviously something I am doing wrong with reference counting in wxPerl; will fix. A caveat: do not use a validator after you did ->SetValidator(); for implementation reasons, once you do ->SetValidator() it is no more valid. Regards Mattia |