From 23da17eef2d506cef6b690d6b362b494c1ed58b7 Mon Sep 17 00:00:00 2001 From: Dmitry Vedenko Date: Thu, 22 Jul 2021 09:31:33 -0700 Subject: [PATCH] For GTK builds - use wxStaticText instead of wxHyperlinkCtrl. It turns out, that wxHyperlinkCtrl has a dramatically different size with the GTK backend. This commit makes link to be only clickable using mouse, but AFAIK accessibility is not implemented for GTK backend anyway. --- src/ui/AccessibleLinksFormatter.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ui/AccessibleLinksFormatter.cpp b/src/ui/AccessibleLinksFormatter.cpp index 65ca3b248..9274eed6e 100644 --- a/src/ui/AccessibleLinksFormatter.cpp +++ b/src/ui/AccessibleLinksFormatter.cpp @@ -15,8 +15,11 @@ #include #include +#ifndef __WXGTK__ #include - +#else +#include +#endif namespace { @@ -108,7 +111,7 @@ void AccessibleLinksFormatter::Populate(ShuttleGui& S) const } // Add hyperlink - +#ifndef __WXGTK__ wxHyperlinkCtrl* hyperlink = safenew wxHyperlinkCtrl( S.GetParent(), wxID_ANY, argument->Value.Translation(), argument->TargetURL); @@ -122,7 +125,18 @@ void AccessibleLinksFormatter::Populate(ShuttleGui& S) const } S.AddWindow(hyperlink, wxALIGN_TOP | wxALIGN_LEFT); +#else + wxStaticText* hyperlink = S.AddVariableText(argument->Value); + hyperlink->SetFont(hyperlink->GetFont().Underlined()); + hyperlink->SetCursor(wxCURSOR_HAND); + hyperlink->Bind(wxEVT_LEFT_UP, [handler = argument->Handler, url = argument->TargetURL](wxEvent&) { + if (handler) + handler(); + else if (!url.empty()) + wxLaunchDefaultBrowser(url); + }); +#endif // Update the currentPostion to the first symbol after the // Placeholder