]> git.saurik.com Git - wxWidgets.git/commitdiff
allow entering multiline tooltips directly; allow removing tooltip by entering empty...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 4 May 2006 15:50:09 +0000 (15:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 4 May 2006 15:50:09 +0000 (15:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/widgets.cpp

index b676beaa1742c3acebac174f95077fa7220663f2..40e8b3b3afebeb8f5e42cf6af78862f62369fee5 100644 (file)
@@ -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