diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp index b582f46fc8..d5a9ae8e9c 100644 --- a/src/html/helpctrl.cpp +++ b/src/html/helpctrl.cpp @@ -405,7 +405,8 @@ bool wxHtmlHelpController::Display(const wxString& x) { CreateHelpWindow(); bool success = m_helpWindow->Display(x); - MakeModalIfNeeded(); + if ( success ) + MakeModalIfNeeded(); return success; } @@ -413,7 +414,8 @@ bool wxHtmlHelpController::Display(int id) { CreateHelpWindow(); bool success = m_helpWindow->Display(id); - MakeModalIfNeeded(); + if ( success ) + MakeModalIfNeeded(); return success; } @@ -421,7 +423,8 @@ bool wxHtmlHelpController::DisplayContents() { CreateHelpWindow(); bool success = m_helpWindow->DisplayContents(); - MakeModalIfNeeded(); + if ( success ) + MakeModalIfNeeded(); return success; } @@ -429,7 +432,8 @@ bool wxHtmlHelpController::DisplayIndex() { CreateHelpWindow(); bool success = m_helpWindow->DisplayIndex(); - MakeModalIfNeeded(); + if ( success ) + MakeModalIfNeeded(); return success; } @@ -438,7 +442,8 @@ bool wxHtmlHelpController::KeywordSearch(const wxString& keyword, { CreateHelpWindow(); bool success = m_helpWindow->KeywordSearch(keyword, mode); - MakeModalIfNeeded(); + if ( success ) + MakeModalIfNeeded(); return success; } diff --git a/tests/html/htmlwindow.cpp b/tests/html/htmlwindow.cpp index 01f17f4a3a..93761917e6 100644 --- a/tests/html/htmlwindow.cpp +++ b/tests/html/htmlwindow.cpp @@ -17,8 +17,11 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/timer.h" #endif // WX_PRECOMP +#include "wx/html/helpctrl.h" +#include "wx/html/helpdlg.h" #include "wx/html/htmlwin.h" #include "wx/uiaction.h" #include "testableframe.h" @@ -43,6 +46,9 @@ private: WXUISIM_TEST( CellClick ); WXUISIM_TEST( LinkClick ); #endif // wxUSE_UIACTIONSIMULATOR +#if wxUSE_WXHTML_HELP + CPPUNIT_TEST( DisplayMissingHelpTopic ); +#endif // wxUSE_WXHTML_HELP CPPUNIT_TEST( ImageMapCoordinates ); CPPUNIT_TEST( AppendToPage ); CPPUNIT_TEST_SUITE_END(); @@ -51,6 +57,9 @@ private: void Title(); void CellClick(); void LinkClick(); +#if wxUSE_WXHTML_HELP + void DisplayMissingHelpTopic(); +#endif // wxUSE_WXHTML_HELP void ImageMapCoordinates(); void AppendToPage(); @@ -110,6 +119,36 @@ static const char *TEST_MARKUP_IMAGEMAP = "" ""; +#if wxUSE_WXHTML_HELP + +class CloseModalHelpDialogTimer : public wxTimer +{ +public: + CloseModalHelpDialogTimer(wxHtmlHelpController& controller) + : m_controller(controller), + m_modalShown(false) + { + } + + bool WasModalShown() const { return m_modalShown; } + +private: + virtual void Notify() override + { + wxHtmlHelpDialog *dialog = m_controller.GetDialog(); + if ( dialog && dialog->IsModal() ) + { + m_modalShown = true; + dialog->EndModal(wxID_CANCEL); + } + } + + wxHtmlHelpController& m_controller; + bool m_modalShown; +}; + +#endif // wxUSE_WXHTML_HELP + static wxHtmlCell *FindCellWithLink(wxHtmlCell *cell, wxPoint *pos) { if ( !cell->GetFirstChild() )