NatureFocus has asked for the wisdom of the Perl Monks concerning the following question:
I am an experienced programmer learning perl by writing a sudoku program and it has gone very well. I am upgrading the cell edit routine (one of a 9x9 matrix) to make it cleaner and am having some trouble. Each cell is square and has 2 lines of up to 5 chars each currently using Tk::text.
I am having trouble filtering out not-allowed chars such as [a..zA..Z] and punctuation chars. I would like a "-validation" command callback like tk::entry has, but I need 2 lines of text. I have read up on bind and bindkey, but they tend to get too kludgy itemizing all the chars to filter out. I need to allow only [1..9], up, down, left, and right and block all else.
I need advice on which approach to use:
1. use the text widget with object/instance binding to bind all the unwanted chars?.
2. text widget subclassing, with text->InsertKeypress() method overridden with some filtering?
3.somehow make the entry widget work in pairs to simulate 2 lines with the first "flowing" into the second? (I have not researched this yet)
4.Some other widget or approach that I don't know about?
If you have any suggestions or words of wisdom, I would be grateful. Thanks -Eugene
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Filtering/validating Tk::text input
by zentara (Cardinal) on Dec 06, 2006 at 13:28 UTC | |
by NatureFocus (Scribe) on Dec 06, 2006 at 19:50 UTC |