I've encountered what appears to be a bug in wxTextCtrl introduced in wxWindows 2.3.3. I'm testing with wxPython, Python 2.2, under MS Windows 98SE and 95, and the problem occurs with wxPython 2.3.3.1, 2.3.4.1, and 2.4.0.2, but not 2.3.2.1.
[I'm posting this to the wx-users list as well, because I suspect it is a wxWindows bug. I don't have wxWindows built for MSW, so I can't readily check this with a C++ sample.]
I am creating a single-line text control as the first control in a
dialog or panel and specifying a non-empty value in the constructor. The text control is going to be added to a wxBoxSizer, so I use wxDefaultSize in the constructor.
When the dialog is initially displayed, the initial text is selected,
but the first part of the text appears cut off. The effect is the same
as if the contents of the control were too long to fit in the single-line control, and the control had therefore auto-scrolled to keep the cursor visible. In fact, the entire text is in the box, and if I scroll left past the visible start of the text, it auto-scrolls just like it would in that situation. The catch is that the text is NOT too long for the control.
I've attached a minimal sample in wxPython which demonstrates this effect (apologies again for not having a comparable C++ wxWindows sample). Note that depending on your font sizes, you may have to fiddle with the value of the initial test to make sure that it is long enough for the effect to occur but not so long that it actually doesn't fit in the text control at its final size.
If I make the initial value in the wxTextCtrl constructor an empty string, and then set it afterwards (e.g. with wxPython wxCallAfter or with a validator), the problem does not occur. Similarly, if I hard-code the size of the control instead of using wxDefaultSize and a box sizer, there is no problem. This leads me to suspect that the problem is caused by the text being set when the text control has default (i.e. 0?) width .
Also, the fact that the problem does not occur in wxPython 2.3.2.1 but does in wxPython 2.3.3.1 suggests that the bug may have been introduced at the same time as the default behavior of text controls was changed to select-all-on-focus.
David
cutoff.py (1.12 KB)