fix wxHyperlinkCtrl opening URL twice, see #13813
(cherry picked from commit 0ff96c620f
)
This commit is contained in:
@@ -35,6 +35,8 @@ public:
|
|||||||
(void)Create(parent, id, label, url, pos, size, style, name);
|
(void)Create(parent, id, label, url, pos, size, style, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~wxHyperlinkCtrl();
|
||||||
|
|
||||||
// Creation function (for two-step construction).
|
// Creation function (for two-step construction).
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
|
@@ -54,19 +54,46 @@ static inline bool UseNative()
|
|||||||
// "clicked"
|
// "clicked"
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __WXGTK3__
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static void gtk_hyperlink_clicked_callback( GtkWidget *WXUNUSED(widget),
|
static gboolean activate_link(GtkWidget*, wxHyperlinkCtrl* win)
|
||||||
wxHyperlinkCtrl *linkCtrl )
|
|
||||||
{
|
{
|
||||||
// send the event
|
win->SendEvent();
|
||||||
linkCtrl->SendEvent();
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static GSList* gs_hyperlinkctrl_list;
|
||||||
|
extern "C" {
|
||||||
|
static void clicked_hook(GtkLinkButton* button, const char*, void*)
|
||||||
|
{
|
||||||
|
for (GSList* p = gs_hyperlinkctrl_list; p; p = p->next)
|
||||||
|
{
|
||||||
|
wxHyperlinkCtrl* win = static_cast<wxHyperlinkCtrl*>(p->data);
|
||||||
|
if (win->m_widget == (GtkWidget*)button)
|
||||||
|
{
|
||||||
|
win->SendEvent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gtk_link_button_set_uri_hook(NULL, NULL, NULL);
|
||||||
|
GTK_BUTTON_GET_CLASS(button)->clicked(GTK_BUTTON(button));
|
||||||
|
gtk_link_button_set_uri_hook(clicked_hook, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxHyperlinkCtrl
|
// wxHyperlinkCtrl
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHyperlinkCtrl::~wxHyperlinkCtrl()
|
||||||
|
{
|
||||||
|
#ifndef __WXGTK3__
|
||||||
|
gs_hyperlinkctrl_list = g_slist_remove(gs_hyperlinkctrl_list, this);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
|
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxString& label, const wxString& url, const wxPoint& pos,
|
const wxString& label, const wxString& url, const wxPoint& pos,
|
||||||
const wxSize& size, long style, const wxString& name)
|
const wxSize& size, long style, const wxString& name)
|
||||||
@@ -98,10 +125,12 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
SetURL(url.empty() ? label : url);
|
SetURL(url.empty() ? label : url);
|
||||||
SetLabel(label.empty() ? url : label);
|
SetLabel(label.empty() ? url : label);
|
||||||
|
|
||||||
// our signal handlers:
|
#ifdef __WXGTK3__
|
||||||
g_signal_connect_after (m_widget, "clicked",
|
g_signal_connect(m_widget, "activate_link", G_CALLBACK(activate_link), this);
|
||||||
G_CALLBACK (gtk_hyperlink_clicked_callback),
|
#else
|
||||||
this);
|
gs_hyperlinkctrl_list = g_slist_prepend(gs_hyperlinkctrl_list, this);
|
||||||
|
gtk_link_button_set_uri_hook(clicked_hook, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_parent->DoAddChild( this );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user