> The fix would be to just always set m_value to the control contents in
> OnOK(), it's not exactly difficult. In fact, we could stop using validator
> for just transferring the value and simply do it manually, simplifying the
> code as we'd get rid of all those "#if wxUSE_VALIDATORS" in it.
>
But then Validate() won't be called at OnOK(). What would be the reason for
using a custom validator if it can't validate, not just filter keys?
> M> Perhaps adding a GetValueAddress(). People creating a custom
> M> wxTextValidator would use this address at its ctor, so 'validator' does
> M> know how to access m_value.
>
> The bad ("surprising") thing is that you don't know you need to do it.
> Even if we document that calling SetTextValidator() means that GetValue()
> doesn't work, half of the people (whom am I kidding... let's say 90% of
> them) won't read this documentation before they hit the bug.
I fully agree.
> If you know
> about it, providing the address of your own wxString is a good enough
> workaround, no need for ugly GetValueAddress().
If the custom validator calls textctrl->ChangeValue(), GetValue() should work.
> The real question is why do we surprise people by default.
I think surprised people have not been a lot, otherwise they had complained ;).
Regards,
Manolo