From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 4 May 2006 15:50:09 +0000 (+0000)
Subject: allow entering multiline tooltips directly; allow removing tooltip by entering empty... 
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/60c84f85016a459f320aa069bf6234d66df92e47

allow entering multiline tooltips directly; allow removing tooltip by entering empty string


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp
index b676beaa17..40e8b3b3af 100644
--- a/samples/widgets/widgets.cpp
+++ b/samples/widgets/widgets.cpp
@@ -513,34 +513,26 @@ void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
 {
     static wxString s_tip = _T("This is a tooltip");
 
-    wxString s = wxGetTextFromUser
-                 (
-                    _T("Tooltip text: "),
-                    _T("Widgets sample"),
-                    s_tip,
-                    this
-                 );
-
-    if ( s.empty() )
+    wxTextEntryDialog dialog
+                      (
+                        this,
+                        _T("Tooltip text (may use \\n, leave empty to remove): "),
+                        _T("Widgets sample"),
+                        s_tip
+                      );
+
+    if ( dialog.ShowModal() != wxID_OK )
         return;
 
-    s_tip = s;
-
-    if( wxMessageBox( _T("Test multiline tooltip text?"),
-                      _T("Widgets sample"),
-                      wxYES_NO,
-                      this
-                    ) == wxYES )
-    {
-        s = _T("#1 ") + s_tip + _T("\n") + _T("#2 ") + s_tip;
-    }
+    s_tip = dialog.GetValue();
+    s_tip.Replace("\\n", "\n");
 
     WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
-    page->GetWidget()->SetToolTip(s);
+    page->GetWidget()->SetToolTip(s_tip);
 
     wxControl *ctrl2 = page->GetWidget2();
     if ( ctrl2 )
-        ctrl2->SetToolTip(s);
+        ctrl2->SetToolTip(s_tip);
 }
 
 #endif // wxUSE_TOOLTIPS