Markus Wankus wrote:
First off - my hat(s) off to everyone involved with the Masked Edit
Control. It is pretty sweet.
(On behalf of myself, Jeff, Werner, and several others who
helped build it-- Thanks!)
Of, course I wouldn't be emailing if I didn't have a question.
I am writing a database app which dynamically generates entry
boxes using masked edit controls. The problem I have is when
editing existing values from the database - it appears as
if the masked edit controls are always in "overwrite-mode".
That is - I fill the control with the text from the
database using .SetValue(), but clicking in the middle of the
edit control and typing does not insert text, it overwrites
what is there.There are a lot of settings available for these things, so I
was wondering if there is one I am not seeing that changes
this behaviour.I am using a simple mask of "X"*10 (for instance), and a
format code of
'_'.
The answer at the moment, I'm afraid, is no.
wxMaskedTextCtrl is designed as a fixed-position,
fixed-width control, with the ability to place fixed
position mask characters in the control and have input
go either up to or around them. Because of this, it
did not make sense to have it "insert" characters,
as this would violate the spirit of the fixed position mask.
Consider a mask of "(###) ###-####"; if you typed in
"1234567890", you get the value "(123) 456-7890" If you
then place the cursor in the middle of this value and start
typing, there is no place for the substring of to the right
of the cursor to go, and in some places in the string, such a
shift would move the mask characters, which is a no-no.
Instead, the character typed is matched against the allowable
characters in that position, and if kosher, that character
replaces the one in the current value (ie. overwrites.)
If the cursor is at a mask position, it automatically
moves to the next editable position and then validates
the keystroke against the legal characters at that position.
In hindsight, the control *could* keep the "input string"
and the value string separate, and insert into the input
string, then re-"paste" the input into the control, and
allow it to insert iff the value was still valid, but we
didn't do this in the current design.
I also suppose it *could* look at the candidate resultant
value after the right-shift of the substring, and if it
still satisfied the mask positions and the character types
for the template then allow the insert, but this would be
a lot over additional overhead in the processing because
it would have to reexamine every character to the right
of the cursor on every keystroke, and so I wouldn't count
on this any time soon...
But I'm still a little unclear on exactly what the
masked control is doing for you...
As you've specified it, ie. a mask of "X"*10 with
a format code of '_', makes little sense to me; this
means "a control of fixed input length 10, allowing
all characters, allowing spaces too. (redundant,
I think... Is this what you want? Are you trying
to just limit input an arbitrary input string to
10 characters? Surely you don't need wxMaskedTextCtrl
for that... a simple EVT_CHAR handler for a wxTextCtrl,
looking at the length of the (stripped) string + 1 and
not calling event.Skip() if it exceeds the length
desired would accomplish this.
What am I missing?
/Will Sadkin
Parlance Corporation
www.nameconnector.com