From b0f7ecbd0d2cc343e84e2937560d17f5970bb765 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Jun 2020 19:16:57 +0200 Subject: [PATCH] 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 --- src/gtk/textctrl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index a5494c269b..4e4cf7a5b5 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -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)