From: Robin Dunn Date: Wed, 8 Mar 2006 23:57:45 +0000 (+0000) Subject: Fix for bug #1436503. Delay the start of the DnD oprtation in case X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/466c166f5adeb00e3a61e9cefb8ab1195380eb5f?ds=inline Fix for bug #1436503. Delay the start of the DnD oprtation in case 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 --- diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index a5e5c66804..815180e1b9 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -49,6 +49,21 @@ private: #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); } @@ -197,11 +212,15 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { sysCaretWidth = 0; sysCaretHeight = 0; #endif +#if wxUSE_DRAG_AND_DROP + startDragTimer = new wxStartDragTimer(this); +#endif } ScintillaWX::~ScintillaWX() { - Finalise(); + delete startDragTimer; + Finalise(); } //---------------------------------------------------------------------- @@ -233,6 +252,14 @@ void ScintillaWX::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 @@ -258,7 +285,6 @@ void ScintillaWX::StartDrag() { inDragDrop = false; SetDragPosition(invalidPosition); } -#endif } @@ -797,6 +823,12 @@ void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, b } 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); } diff --git a/contrib/src/stc/ScintillaWX.h b/contrib/src/stc/ScintillaWX.h index e703efe606..c945804fce 100644 --- a/contrib/src/stc/ScintillaWX.h +++ b/contrib/src/stc/ScintillaWX.h @@ -142,6 +142,7 @@ public: 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); @@ -173,7 +174,9 @@ private: #if wxUSE_DRAG_AND_DROP wxSTCDropTarget* dropTarget; wxDragResult dragResult; + wxTimer* startDragTimer; #endif + int wheelRotation; // For use in creating a system caret @@ -185,7 +188,7 @@ private: int sysCaretWidth; int sysCaretHeight; #endif - + friend class wxSTCCallTip; }; diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index a5e5c66804..815180e1b9 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -49,6 +49,21 @@ private: #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); } @@ -197,11 +212,15 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { sysCaretWidth = 0; sysCaretHeight = 0; #endif +#if wxUSE_DRAG_AND_DROP + startDragTimer = new wxStartDragTimer(this); +#endif } ScintillaWX::~ScintillaWX() { - Finalise(); + delete startDragTimer; + Finalise(); } //---------------------------------------------------------------------- @@ -233,6 +252,14 @@ void ScintillaWX::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 @@ -258,7 +285,6 @@ void ScintillaWX::StartDrag() { inDragDrop = false; SetDragPosition(invalidPosition); } -#endif } @@ -797,6 +823,12 @@ void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, b } 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); } diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index e703efe606..c945804fce 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -142,6 +142,7 @@ public: 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); @@ -173,7 +174,9 @@ private: #if wxUSE_DRAG_AND_DROP wxSTCDropTarget* dropTarget; wxDragResult dragResult; + wxTimer* startDragTimer; #endif + int wheelRotation; // For use in creating a system caret @@ -185,7 +188,7 @@ private: int sysCaretWidth; int sysCaretHeight; #endif - + friend class wxSTCCallTip; };