- startPos = obj->GetRange().GetStart();
- endPos = obj->GetRange().GetEnd();
- }
-
- wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos);
- InitCommandEvent(urlEvent);
-
- urlEvent.SetString(urlTarget);
-
- GetEventHandler()->ProcessEvent(urlEvent);
+ 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);
+ }