wxHyperlinkCtrl - hover color and visited color not working on Mac

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

wxHyperlinkCtrl - hover color and visited color not working on Mac

Post 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")));
User avatar
doublemax
Moderator
Moderator
Posts: 19112
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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>
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post by deepti »

wxGenericHyperlinkCtrl does not work either :(
Is there anything else I could try?
User avatar
doublemax
Moderator
Moderator
Posts: 19112
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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);
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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!
User avatar
doublemax
Moderator
Moderator
Posts: 19112
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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?
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19112
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax »

Works with all colors, for all three settings (normal/hover/visited).
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post 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.
Post Reply