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
This commit is contained in:
@@ -49,6 +49,21 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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) {
|
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
|
||||||
return swx->DoDropText(x, y, data);
|
return swx->DoDropText(x, y, data);
|
||||||
}
|
}
|
||||||
@@ -197,11 +212,15 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
|||||||
sysCaretWidth = 0;
|
sysCaretWidth = 0;
|
||||||
sysCaretHeight = 0;
|
sysCaretHeight = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
startDragTimer = new wxStartDragTimer(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScintillaWX::~ScintillaWX() {
|
ScintillaWX::~ScintillaWX() {
|
||||||
Finalise();
|
delete startDragTimer;
|
||||||
|
Finalise();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@@ -233,6 +252,14 @@ void ScintillaWX::Finalise() {
|
|||||||
|
|
||||||
void ScintillaWX::StartDrag() {
|
void ScintillaWX::StartDrag() {
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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);
|
wxString dragText = stc2wx(drag.s, drag.len);
|
||||||
|
|
||||||
// Send an event to allow the drag text to be changed
|
// Send an event to allow the drag text to be changed
|
||||||
@@ -258,7 +285,6 @@ void ScintillaWX::StartDrag() {
|
|||||||
inDragDrop = false;
|
inDragDrop = false;
|
||||||
SetDragPosition(invalidPosition);
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -142,6 +142,7 @@ public:
|
|||||||
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
||||||
void DoTick() { Tick(); }
|
void DoTick() { Tick(); }
|
||||||
void DoOnIdle(wxIdleEvent& evt);
|
void DoOnIdle(wxIdleEvent& evt);
|
||||||
|
void DoStartDrag();
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
bool DoDropText(long x, long y, const wxString& data);
|
bool DoDropText(long x, long y, const wxString& data);
|
||||||
@@ -173,7 +174,9 @@ private:
|
|||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
wxSTCDropTarget* dropTarget;
|
wxSTCDropTarget* dropTarget;
|
||||||
wxDragResult dragResult;
|
wxDragResult dragResult;
|
||||||
|
wxTimer* startDragTimer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int wheelRotation;
|
int wheelRotation;
|
||||||
|
|
||||||
// For use in creating a system caret
|
// For use in creating a system caret
|
||||||
@@ -185,7 +188,7 @@ private:
|
|||||||
int sysCaretWidth;
|
int sysCaretWidth;
|
||||||
int sysCaretHeight;
|
int sysCaretHeight;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
friend class wxSTCCallTip;
|
friend class wxSTCCallTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -49,6 +49,21 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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) {
|
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
|
||||||
return swx->DoDropText(x, y, data);
|
return swx->DoDropText(x, y, data);
|
||||||
}
|
}
|
||||||
@@ -197,11 +212,15 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
|||||||
sysCaretWidth = 0;
|
sysCaretWidth = 0;
|
||||||
sysCaretHeight = 0;
|
sysCaretHeight = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
startDragTimer = new wxStartDragTimer(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScintillaWX::~ScintillaWX() {
|
ScintillaWX::~ScintillaWX() {
|
||||||
Finalise();
|
delete startDragTimer;
|
||||||
|
Finalise();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@@ -233,6 +252,14 @@ void ScintillaWX::Finalise() {
|
|||||||
|
|
||||||
void ScintillaWX::StartDrag() {
|
void ScintillaWX::StartDrag() {
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#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);
|
wxString dragText = stc2wx(drag.s, drag.len);
|
||||||
|
|
||||||
// Send an event to allow the drag text to be changed
|
// Send an event to allow the drag text to be changed
|
||||||
@@ -258,7 +285,6 @@ void ScintillaWX::StartDrag() {
|
|||||||
inDragDrop = false;
|
inDragDrop = false;
|
||||||
SetDragPosition(invalidPosition);
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -142,6 +142,7 @@ public:
|
|||||||
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
||||||
void DoTick() { Tick(); }
|
void DoTick() { Tick(); }
|
||||||
void DoOnIdle(wxIdleEvent& evt);
|
void DoOnIdle(wxIdleEvent& evt);
|
||||||
|
void DoStartDrag();
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
bool DoDropText(long x, long y, const wxString& data);
|
bool DoDropText(long x, long y, const wxString& data);
|
||||||
@@ -173,7 +174,9 @@ private:
|
|||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
wxSTCDropTarget* dropTarget;
|
wxSTCDropTarget* dropTarget;
|
||||||
wxDragResult dragResult;
|
wxDragResult dragResult;
|
||||||
|
wxTimer* startDragTimer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int wheelRotation;
|
int wheelRotation;
|
||||||
|
|
||||||
// For use in creating a system caret
|
// For use in creating a system caret
|
||||||
@@ -185,7 +188,7 @@ private:
|
|||||||
int sysCaretWidth;
|
int sysCaretWidth;
|
||||||
int sysCaretHeight;
|
int sysCaretHeight;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
friend class wxSTCCallTip;
|
friend class wxSTCCallTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user