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
This commit is contained in:
Vadim Zeitlin
2006-05-04 15:50:09 +00:00
parent bf00495160
commit 60c84f8501

View File

@@ -513,34 +513,26 @@ void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
{ {
static wxString s_tip = _T("This is a tooltip"); static wxString s_tip = _T("This is a tooltip");
wxString s = wxGetTextFromUser wxTextEntryDialog dialog
( (
_T("Tooltip text: "), this,
_T("Widgets sample"), _T("Tooltip text (may use \\n, leave empty to remove): "),
s_tip, _T("Widgets sample"),
this s_tip
); );
if ( s.empty() ) if ( dialog.ShowModal() != wxID_OK )
return; return;
s_tip = s; s_tip = dialog.GetValue();
s_tip.Replace("\\n", "\n");
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;
}
WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage); WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
page->GetWidget()->SetToolTip(s); page->GetWidget()->SetToolTip(s_tip);
wxControl *ctrl2 = page->GetWidget2(); wxControl *ctrl2 = page->GetWidget2();
if ( ctrl2 ) if ( ctrl2 )
ctrl2->SetToolTip(s); ctrl2->SetToolTip(s_tip);
} }
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS