+
+ // See if we clicked on a URL
+ wxClientDC dc(this);
+ PrepareDC(dc);
+ dc.SetFont(GetFont());
+
+ long position = 0;
+ wxPoint logicalPt = event.GetLogicalPosition(dc);
+ int hit = GetBuffer().HitTest(dc, logicalPt, position);
+
+ if (hit != wxRICHTEXT_HITTEST_NONE)
+ {
+ wxRichTextEvent cmdEvent(
+ wxEVT_COMMAND_RICHTEXT_LEFT_CLICK,
+ GetId());
+ cmdEvent.SetEventObject(this);
+ cmdEvent.SetPosition(m_caretPosition+1);
+
+ if (!GetEventHandler()->ProcessEvent(cmdEvent))
+ {
+ wxTextAttr attr;
+ if (GetStyle(position, attr))
+ {
+ if (attr.HasFlag(wxTEXT_ATTR_URL))
+ {
+ wxString urlTarget = attr.GetURL();
+ if (!urlTarget.IsEmpty())
+ {
+ wxMouseEvent mouseEvent(event);
+
+ long startPos = 0, endPos = 0;
+ wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position);
+ if (obj)
+ {
+ startPos = obj->GetRange().GetStart();
+ endPos = obj->GetRange().GetEnd();
+ }
+
+ wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos);
+ InitCommandEvent(urlEvent);
+
+ urlEvent.SetString(urlTarget);
+
+ GetEventHandler()->ProcessEvent(urlEvent);
+ }
+ }
+ }
+ }
+ }