From 7206194d087a8ff27ab81237131806508c85b6ac Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Jul 2019 11:08:53 +0200 Subject: [PATCH] Show new wxTextCtrl value in the widgets sample This is useful for quickly checking that we're getting expected events when modifying the control and/or not getting any unexpected ones and was already done on wxComboBox page, but not for wxTextCtrl. --- samples/widgets/textctrl.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 8618261215..cda0bc9362 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -31,6 +31,7 @@ #include "wx/bitmap.h" #include "wx/button.h" #include "wx/checkbox.h" + #include "wx/dcclient.h" #include "wx/radiobox.h" #include "wx/statbox.h" #include "wx/stattext.h" @@ -986,7 +987,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) (m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) ); } -void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event)) +void TextWidgetsPage::OnText(wxCommandEvent& event) { // small hack to suppress the very first message: by then the logging is // not yet redirected and so initial setting of the text value results in @@ -998,7 +999,16 @@ void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event)) return; } - wxLogMessage("Text ctrl value changed"); + // Replace middle of long text with ellipsis just to avoid filling up the + // log control with too much unnecessary stuff. + wxLogMessage("Text control value changed (now '%s')", + wxControl::Ellipsize + ( + event.GetString(), + wxClientDC(this), + wxELLIPSIZE_MIDDLE, + GetTextExtent('W').x*100 + )); } void TextWidgetsPage::OnTextEnter(wxCommandEvent& event)