David C. Fox wrote:
I have two text ctrls. One is enabled, one is disabled. Can I link the
two controls so that when the user types in the enabled text ctrl, the
text also appears in the disabled text ctrl? Also, I am validating the
enabled text ctrl using the onChar property of wxValidator.Any suggestions?
Just catch the OnChar event of the enabled control, and in the event
handling function you write the text to the disabled one.Horst
I cannot get this to work. I assume that you should put the EVT_CHAR in the panel which contains the TextCtrls? The event does not seem to catch any key presses. Is it because I have validators for the TextCtrls which are also catching keypresses?
James Shaw
Could be, but it is hard to tell without seeing your source code. Here
is an example using a custom validator, where both the validation and
copying content from one text control to the other work simultaneously
(at least in Windows). For simplicity, I've borrowed the validator from
the demo code, so you'll have to copy wxValidator.py from
Python/wxPython/demo to the current directory or to somewhere in your
Python path.
Also, I update the second text control by copying the contents and
selection from the first text control after each keystroke event, rather
than actually sending keystrokes to the second control. I had another
version where I tried re-directing the key events to the second control,
but it didn't work, and I didn't want to go through the bother of
emulating the effects of Backspace, Del, arrow keys, etc. This approach
also correctly handles the effect of cutting and pasting by keyboard,
though that is more by happy accident than by design.
Of course, if you are using a custom validator, you could presumably
move the stuff from my OnEditorChar into the validator's OnChar (unless
you want to reuse the validator class).
David
···
-------
Cheers David. Your code works just as I wanted. Just one thing: the dictated TextCtrl doesn't refresh after cut/paste/delete operations if they are selected from the popup menu (right-click on the control). Could this be fixed?
Also, I'm a newbie to posting messages on newsgroups and I don't know how to reply to a message so that it appears as a reply in the thread view.
James Shaw
_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail. http://www.hotmail.com