- wxDropSource source(wMain.GetID());
- wxTextDataObject data(dragChars);
- wxDragResult result;
-
- source.SetData(data);
- result = source.DoDragDrop(TRUE);
- if (result == wxDragMove && dropWentOutside)
- ClearSelection();
- inDragDrop = FALSE;
- SetDragPosition(invalidPosition);
+#if wxUSE_DRAG_AND_DROP
+ wxString dragText(drag.s, wxConvUTF8, drag.len);
+
+ // Send an event to allow the drag text to be changed
+ wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
+ evt.SetEventObject(stc);
+ evt.SetDragText(dragText);
+ evt.SetDragAllowMove(TRUE);
+ evt.SetPosition(wxMin(stc->GetSelectionStart(),
+ stc->GetSelectionEnd()));
+ stc->GetEventHandler()->ProcessEvent(evt);
+ dragText = evt.GetDragText();
+
+ if (dragText.Length()) {
+ wxDropSource source(stc);
+ wxTextDataObject data(dragText);
+ wxDragResult result;
+
+ source.SetData(data);
+ dropWentOutside = TRUE;
+ result = source.DoDragDrop(evt.GetDragAllowMove());
+ if (result == wxDragMove && dropWentOutside)
+ ClearSelection();
+ inDragDrop = FALSE;
+ SetDragPosition(invalidPosition);
+ }
+#endif