Fix the initial wxTextCtrl size in wxGTK

We need to explicitly call SetInitialSize() after setting the value of
the control (if it's not empty), as the first call, done from inside of
PostCreation(), doesn't take the initial control contents into account
and so doesn't allocate the height correctly for multiline text controls
containing more than 2 lines of text, for example.

Closes https://github.com/wxWidgets/wxWidgets/pull/1891
This commit is contained in:
Vadim Zeitlin
2020-06-10 19:16:57 +02:00
parent dc92f2e9dc
commit b0f7ecbd0d

View File

@@ -817,7 +817,14 @@ bool wxTextCtrl::Create( wxWindow *parent,
if (!value.empty())
{
ChangeValue(value);
InvalidateBestSize();
// The call to SetInitialSize() from inside PostCreation() didn't take
// the value into account because it hadn't been set yet when it was
// called (and setting it earlier wouldn't have been correct neither,
// as the appropriate size depends on the presence of the borders,
// which are configured in PostCreation()), so recompute the initial
// size again now that we have set it.
SetInitialSize(size);
}
if (style & wxTE_PASSWORD)