Contents Up Previous Next

wxHyperlinkCtrl

This class shows a static text element which links to an URL. Appearance and behaviour is completely customizable. In fact, when the user clicks on the hyperlink, a wxHyperlinkEvent is sent but if that event is not handled (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser is done with the hyperlink's URL.

Note that standard wxWindow functions like SetBackgroundColour, SetFont, SetCursor, SetLabel can be used to customize appearance of the hyperlink.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/hyperlink.h>

Window styles

wxHL_ALIGN_LEFT Align the text to the left.
wxHL_ALIGN_RIGHT Align the text to the right.
wxHL_ALIGN_CENTRE Center the text (horizontally).
wxHL_CONTEXTMENU Pop up a context menu when the hyperlink is right-clicked. The context menu contains a "Copy URL" menu item which is automatically handled by the hyperlink and which just copies in the clipboard the URL (not the label) of the control.
wxHL_DEFAULT_STYLE The default style for wxHyperlinkCtrl: wxNO_BORDER|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.

See also window styles overview.

Event handling

To process input from an hyperlink control, use these event handler macros to direct input to member functions that take a wxHyperlinkEvent argument.

EVT_HYPERLINK(id, func) The hyperlink was (left) clicked. If this event is not handled in user's code (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser is done with the hyperlink's URL.

See also

wxURL, wxHyperlinkEvent

Members

wxHyperlinkCtrl::wxHyperLink
wxHyperlinkCtrl::Create
wxHyperlinkCtrl::GetHoverColour
wxHyperlinkCtrl::SetHoverColour
wxHyperlinkCtrl::GetNormalColour
wxHyperlinkCtrl::SetNormalColour
wxHyperlinkCtrl::GetVisitedColour
wxHyperlinkCtrl::SetVisitedColour
wxHyperlinkCtrl::GetVisited
wxHyperlinkCtrl::SetVisited
wxHyperlinkCtrl::GetURL
wxHyperlinkCtrl::SetURL


wxHyperlinkCtrl::wxHyperLink

wxHyperLink(wxWindow* parent, wxWindowID id, const wxString & label, const wxString & url, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style, const wxString& name = "hyperlink")

Constructor. See Create for more info.


wxHyperlinkCtrl::Create

bool Create(wxWindow* parent, wxWindowID id, const wxString & label, const wxString & url, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style, const wxString& name = "hyperlink")

Creates the hyperlink control.

Parameters

parent

id

label

url

pos

size

style

validator

name


wxHyperlinkCtrl::GetHoverColour

wxColour GetHoverColour() const

Returns the colour used to print the label of the hyperlink when the mouse is over the control.


wxHyperlinkCtrl::SetHoverColour

void SetHoverColour(const wxColour & colour)

Sets the colour used to print the label of the hyperlink when the mouse is over the control.


wxHyperlinkCtrl::GetNormalColour

wxColour GetNormalColour() const

Returns the colour used to print the label when the link has never been clicked before (i.e. the link has not been visited) and the mouse is not over the control.


wxHyperlinkCtrl::SetNormalColour

void SetNormalColour(const wxColour & colour)

Sets the colour used to print the label when the link has never been clicked before (i.e. the link has not been visited) and the mouse is not over the control.


wxHyperlinkCtrl::GetVisitedColour

wxColour GetVisitedColour() const

Returns the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e. the link has been visited).


wxHyperlinkCtrl::SetVisitedColour

void SetVisitedColour(const wxColour & colour)

Sets the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e. the link has been visited).


wxHyperlinkCtrl::GetVisited

bool GetVisited() const

Returns true if the hyperlink has already been clicked by the user at least one time.


wxHyperlinkCtrl::SetVisited

void SetVisited(bool visited = true)

Marks the hyperlink as visited (see SetVisitedColour).


wxHyperlinkCtrl::GetURL

wxString GetURL() const

Returns the URL associated with the hyperlink.


wxHyperlinkCtrl::SetURL

void SetURL(const wxString & url)

Sets the URL associated with the hyperlink.