Page 1 of 1

wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 6:27 am
by deepti
Hi,

I have a wxHyperlinkCtrl instance. On Mac, when the mouse is hovered over the control, or the link is clicked, the color changes to red and purple respectively.
I am using the following functions, and setting the color to blue but they are not having any effect, and hover and click colors are still red and purple!

Code: Select all

   m_hyperLink->SetNormalColour(wxColour(_T("#0000FF")));
   m_hyperLink->SetHoverColour(wxColour(_T("#0000FF")));
   m_hyperLink->SetVisitedColour(wxColour(_T("#0000FF")));

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 7:23 am
by doublemax
I don't work under OSX, so i can't test this, but most likely the native control under OSX does not support this. Apple has very strict UI guidelines. And i would suggest to follow those.

If you really want different colors, you can try wxGenericHyperlinkCtrl.
You need to #include <wx/generic/hyperlink.h>

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 7:30 am
by deepti
Thank you for your reply @doublemax.

In fact, i do not want the colours of wxHyperlinkCtrl to change, which is the default behavior on Windows.

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 10:35 am
by deepti
wxGenericHyperlinkCtrl does not work either :(
Is there anything else I could try?

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 12:14 pm
by doublemax
That's strange. I tested it under Windows and it worked fine.

In the "widgets" sample, in the file "hyperlnk.cpp", method HyperlinkWidgetsPage::CreateHyperlink, i added:

Code: Select all

        hyp->SetNormalColour(wxColour(_T("#0000FF")));
        hyp->SetHoverColour(wxColour(_T("#0000FF")));
        hyp->SetVisitedColour(wxColour(_T("#0000FF")));
right after:

Code: Select all

    wxGenericHyperlinkCtrl *hyp;
    if (m_checkGeneric->IsChecked())
    {
        hyp = new wxGenericHyperlinkCtrl(this,
                                  HyperlinkPage_Ctrl,
                                  label,
                                  url);

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 5:24 pm
by deepti
Yes, it works fine on Windows.. but has no effect on Mac :(
Is there any other way we can get it working for Mac? Please help!

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Thu Feb 14, 2019 7:08 pm
by doublemax
I got OSX working in a VM and tested it, but it worked for me with the code i showed before.

How exactly did you test this? Are you sure the code you edited is actually executed?

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Fri Feb 15, 2019 2:36 am
by deepti
oh wow!! thanks a ton for trying out.
Yes, it executed that code.
To me, it seems like since blue is the default color, it seems to be working.
If you get a chance, could you change the color, to say, red, and try please?
I am also trying another time at my end.

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Fri Feb 15, 2019 4:48 am
by deepti
oh wow!! thanks a ton for trying out.
To me, it seems like since blue is the default color, it seems to be working.
If you get a chance, could you change the color, to say, red, and try please?
I am also trying another time at my end.

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Fri Feb 15, 2019 8:00 am
by doublemax
Works with all colors, for all three settings (normal/hover/visited).

Re: wxHyperlinkCtrl - hover color and visited color not working on Mac

Posted: Wed Feb 20, 2019 7:03 pm
by ONEEYEMAN
Hi,
According to the source, OSX is using generic control:

Code: Select all

#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__)
    #include "wx/gtk/hyperlink.h"
// Note that the native control is only available in Unicode version under MSW.
#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__)
    #include "wx/msw/hyperlink.h"
#else
    #include "wx/generic/hyperlink.h"

    class WXDLLIMPEXP_CORE wxHyperlinkCtrl : public wxGenericHyperlinkCtrl
    {
    public:
        wxHyperlinkCtrl() { }

        wxHyperlinkCtrl(wxWindow *parent,
                        wxWindowID id,
                        const wxString& label,
                        const wxString& url,
                        const wxPoint& pos = wxDefaultPosition,
                        const wxSize& size = wxDefaultSize,
                        long style = wxHL_DEFAULT_STYLE,
                        const wxString& name = wxHyperlinkCtrlNameStr)
            : wxGenericHyperlinkCtrl(parent, id, label, url, pos, size,
                                     style, name)
        {
        }

    private:
        wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxHyperlinkCtrl );
    };
#endif
Thank you.