the user just intended to click, not drag.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37906
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
+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);
}
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
+#if wxUSE_DRAG_AND_DROP
+ startDragTimer = new wxStartDragTimer(this);
+#endif
}
ScintillaWX::~ScintillaWX() {
}
ScintillaWX::~ScintillaWX() {
+ delete startDragTimer;
+ Finalise();
}
//----------------------------------------------------------------------
}
//----------------------------------------------------------------------
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
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
wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
inDragDrop = false;
SetDragPosition(invalidPosition);
}
inDragDrop = false;
SetDragPosition(invalidPosition);
}
}
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
}
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);
}
ButtonUp(pt, curTime, ctrl);
}
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
+ wxTimer* startDragTimer;
int wheelRotation;
// For use in creating a system caret
int wheelRotation;
// For use in creating a system caret
int sysCaretWidth;
int sysCaretHeight;
#endif
int sysCaretWidth;
int sysCaretHeight;
#endif
friend class wxSTCCallTip;
};
friend class wxSTCCallTip;
};
+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);
}
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
+#if wxUSE_DRAG_AND_DROP
+ startDragTimer = new wxStartDragTimer(this);
+#endif
}
ScintillaWX::~ScintillaWX() {
}
ScintillaWX::~ScintillaWX() {
+ delete startDragTimer;
+ Finalise();
}
//----------------------------------------------------------------------
}
//----------------------------------------------------------------------
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
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
wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
inDragDrop = false;
SetDragPosition(invalidPosition);
}
inDragDrop = false;
SetDragPosition(invalidPosition);
}
}
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
}
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);
}
ButtonUp(pt, curTime, ctrl);
}
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
void DoTick() { Tick(); }
void DoOnIdle(wxIdleEvent& evt);
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
bool DoDropText(long x, long y, const wxString& data);
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
#if wxUSE_DRAG_AND_DROP
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
+ wxTimer* startDragTimer;
int wheelRotation;
// For use in creating a system caret
int wheelRotation;
// For use in creating a system caret
int sysCaretWidth;
int sysCaretHeight;
#endif
int sysCaretWidth;
int sysCaretHeight;
#endif
friend class wxSTCCallTip;
};
friend class wxSTCCallTip;
};