From 3e246c767f33994287a56aa5231d00003ca0a95a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Nov 2018 19:35:44 +0100 Subject: [PATCH] Return true from wxHyperlinkCtrl::MSWOnNotify() As SendEvent() not only sends the event about clicking on the link, but also opens the link in the default browser if this event was not processed (which wasn't really obvious from its name, so at least mention it in its comment), the event is actually always handled and so MSWOnNotify() must return true, not false (and definitely not 0) to indicate it. Closes #18266. --- include/wx/hyperlink.h | 3 +++ src/msw/hyperlink.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/wx/hyperlink.h b/include/wx/hyperlink.h index 237dadca85..072c05efd3 100644 --- a/include/wx/hyperlink.h +++ b/include/wx/hyperlink.h @@ -76,6 +76,9 @@ protected: void CheckParams(const wxString& label, const wxString& url, long style); public: + // Send wxHyperlinkEvent and open our link in the default browser if it + // wasn't handled. + // // not part of the public API but needs to be public as used by // GTK+ callbacks: void SendEvent(); diff --git a/src/msw/hyperlink.cpp b/src/msw/hyperlink.cpp index f39d94ae17..adb922de74 100644 --- a/src/msw/hyperlink.cpp +++ b/src/msw/hyperlink.cpp @@ -174,7 +174,12 @@ bool wxHyperlinkCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case NM_RETURN: SetVisited(); SendEvent(); - return 0; + + // SendEvent() launches the browser by default, so we consider + // that the event was processed in any case, either by user + // code or by wx itself, hence we always return true to + // indicate that the default processing shouldn't take place. + return true; } }