#if wxUSE_DRAG_AND_DROP
+class wxStartDragTimer : public wxTimer {
+public:
+ wxStartDragTimer(ScintillaWX* swx) {
+ this->swx = swx;
+ }
+
+ void Notify() {
+ swx->DoStartDrag();
+ }
+
+private:
+ ScintillaWX* swx;
+};
+
+
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
+#if wxUSE_DRAG_AND_DROP
+ startDragTimer = new wxStartDragTimer(this);
+#endif
}
ScintillaWX::~ScintillaWX() {
- Finalise();
+ delete startDragTimer;
+ Finalise();
}
//----------------------------------------------------------------------
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
+ // We defer the starting of the DnD, otherwise the LeftUp of a normal
+ // click could be lost and the STC will think it is doing a DnD when the
+ // user just wanted a normal click.
+ startDragTimer->Start(100, true);
+#endif
+}
+
+void ScintillaWX::DoStartDrag() {
wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
inDragDrop = false;
SetDragPosition(invalidPosition);
}
-#endif
}
}
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
+#if wxUSE_DRAG_AND_DROP
+ if (startDragTimer->IsRunning()) {
+ startDragTimer->Stop();
+ SetEmptySelection(PositionFromLocation(pt));
+ }
+#endif
ButtonUp(pt, curTime, ctrl);
}
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
+ void DoStartDrag();
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
+ wxTimer* startDragTimer;
#endif
+
int wheelRotation;
// For use in creating a system caret
int sysCaretWidth;
int sysCaretHeight;
#endif
-
+
friend class wxSTCCallTip;
};
#if wxUSE_DRAG_AND_DROP
+class wxStartDragTimer : public wxTimer {
+public:
+ wxStartDragTimer(ScintillaWX* swx) {
+ this->swx = swx;
+ }
+
+ void Notify() {
+ swx->DoStartDrag();
+ }
+
+private:
+ ScintillaWX* swx;
+};
+
+
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
+#if wxUSE_DRAG_AND_DROP
+ startDragTimer = new wxStartDragTimer(this);
+#endif
}
ScintillaWX::~ScintillaWX() {
- Finalise();
+ delete startDragTimer;
+ Finalise();
}
//----------------------------------------------------------------------
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
+ // We defer the starting of the DnD, otherwise the LeftUp of a normal
+ // click could be lost and the STC will think it is doing a DnD when the
+ // user just wanted a normal click.
+ startDragTimer->Start(100, true);
+#endif
+}
+
+void ScintillaWX::DoStartDrag() {
wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
inDragDrop = false;
SetDragPosition(invalidPosition);
}
-#endif
}
}
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
+#if wxUSE_DRAG_AND_DROP
+ if (startDragTimer->IsRunning()) {
+ startDragTimer->Stop();
+ SetEmptySelection(PositionFromLocation(pt));
+ }
+#endif
ButtonUp(pt, curTime, ctrl);
}
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
+ void DoStartDrag();
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
+ wxTimer* startDragTimer;
#endif
+
int wheelRotation;
// For use in creating a system caret
int sysCaretWidth;
int sysCaretHeight;
#endif
-
+
friend class wxSTCCallTip;
};