On wxGTK the Primary Selection is now set when something is selected
in wxSTC, and the middle mouse button will paste from the PrimarySelection. Regular Cut/Copy/Paste explicitly uses the normal clipboard selection. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1942,6 +1942,7 @@ private:
|
||||
void OnMouseMove(wxMouseEvent& evt);
|
||||
void OnMouseLeftUp(wxMouseEvent& evt);
|
||||
void OnMouseRightUp(wxMouseEvent& evt);
|
||||
void OnMouseMiddleUp(wxMouseEvent& evt);
|
||||
void OnContextMenu(wxContextMenuEvent& evt);
|
||||
void OnMouseWheel(wxMouseEvent& evt);
|
||||
void OnChar(wxKeyEvent& evt);
|
||||
|
@@ -338,7 +338,7 @@ void ScintillaWX::Copy() {
|
||||
SelectionText st;
|
||||
CopySelectionRange(&st);
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection();
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
wxString text = stc2wx(st.s, st.len);
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->Close();
|
||||
@@ -355,7 +355,7 @@ void ScintillaWX::Paste() {
|
||||
bool gotData = FALSE;
|
||||
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection();
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
gotData = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
@@ -380,7 +380,7 @@ bool ScintillaWX::CanPaste() {
|
||||
wxTheClipboard->Open();
|
||||
|
||||
if (wxTheClipboard->IsOpened()) {
|
||||
wxTheClipboard->UsePrimarySelection();
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
|
||||
if (didOpen)
|
||||
wxTheClipboard->Close();
|
||||
@@ -405,8 +405,22 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
}
|
||||
|
||||
|
||||
// This is called by the Editor base class whenever something is selected
|
||||
void ScintillaWX::ClaimSelection() {
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Put the selected text in the PRIMARY selection
|
||||
if (currentPos != anchor) {
|
||||
SelectionText st;
|
||||
CopySelectionRange(&st);
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection(TRUE);
|
||||
wxString text = stc2wx(st.s, st.len);
|
||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -547,18 +561,49 @@ void ScintillaWX::DoSysColourChange() {
|
||||
InvalidateStyleData();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
||||
void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
||||
ButtonDown(pt, curTime, shift, ctrl, alt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
||||
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
||||
ButtonUp(pt, curTime, ctrl);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoButtonMove(Point pt) {
|
||||
void ScintillaWX::DoLeftButtonMove(Point pt) {
|
||||
ButtonMove(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
||||
#ifdef __WXGTK__
|
||||
// Set the current position to the mouse click point and
|
||||
// then paste in the PRIMARY selection, if any. wxGTK only.
|
||||
int newPos = PositionFromLocation(pt);
|
||||
MovePositionTo(newPos, 0, 1);
|
||||
|
||||
pdoc->BeginUndoAction();
|
||||
wxTextDataObject data;
|
||||
bool gotData = FALSE;
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->UsePrimarySelection(TRUE);
|
||||
gotData = wxTheClipboard->GetData(data);
|
||||
wxTheClipboard->UsePrimarySelection(FALSE);
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
if (gotData) {
|
||||
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
|
||||
int len = strlen(buf);
|
||||
pdoc->InsertString(currentPos, buf, len);
|
||||
SetEmptySelection(currentPos + len);
|
||||
}
|
||||
pdoc->EndUndoAction();
|
||||
NotifyChange();
|
||||
Redraw();
|
||||
|
||||
ShowCaretAtCurrentPosition();
|
||||
EnsureCaretVisible();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(int key) {
|
||||
#if wxUSE_UNICODE
|
||||
|
@@ -122,9 +122,10 @@ public:
|
||||
void DoLoseFocus();
|
||||
void DoGainFocus();
|
||||
void DoSysColourChange();
|
||||
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||
void DoButtonMove(Point pt);
|
||||
void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||
void DoLeftButtonMove(Point pt);
|
||||
void DoMiddleButtonUp(Point pt);
|
||||
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
|
||||
void DoAddChar(int key);
|
||||
int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
|
||||
|
@@ -90,10 +90,8 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_SCROLL (wxStyledTextCtrl::OnScroll)
|
||||
EVT_SIZE (wxStyledTextCtrl::OnSize)
|
||||
EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
// Let Scintilla see the double click as a second click
|
||||
EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
|
||||
#endif
|
||||
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
|
||||
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
|
||||
#if defined(__WXGTK__) || defined(__WXMAC__)
|
||||
@@ -102,6 +100,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
|
||||
#endif
|
||||
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
|
||||
EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
|
||||
EVT_CHAR (wxStyledTextCtrl::OnChar)
|
||||
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
|
||||
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
|
||||
@@ -1959,18 +1958,18 @@ void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
|
||||
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
|
||||
SetFocus();
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonMove(Point(pt.x, pt.y));
|
||||
m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ControlDown());
|
||||
}
|
||||
|
||||
@@ -1981,6 +1980,11 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
ScreenToClient(&pt.x, &pt.y);
|
||||
|
@@ -90,10 +90,8 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_SCROLL (wxStyledTextCtrl::OnScroll)
|
||||
EVT_SIZE (wxStyledTextCtrl::OnSize)
|
||||
EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
// Let Scintilla see the double click as a second click
|
||||
EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
|
||||
#endif
|
||||
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
|
||||
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
|
||||
#if defined(__WXGTK__) || defined(__WXMAC__)
|
||||
@@ -102,6 +100,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
|
||||
#endif
|
||||
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
|
||||
EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
|
||||
EVT_CHAR (wxStyledTextCtrl::OnChar)
|
||||
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
|
||||
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
|
||||
@@ -337,18 +336,18 @@ void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
|
||||
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
|
||||
SetFocus();
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonMove(Point(pt.x, pt.y));
|
||||
m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
|
||||
evt.ControlDown());
|
||||
}
|
||||
|
||||
@@ -359,6 +358,11 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
|
||||
wxPoint pt = evt.GetPosition();
|
||||
ScreenToClient(&pt.x, &pt.y);
|
||||
|
@@ -184,6 +184,7 @@ private:
|
||||
void OnMouseMove(wxMouseEvent& evt);
|
||||
void OnMouseLeftUp(wxMouseEvent& evt);
|
||||
void OnMouseRightUp(wxMouseEvent& evt);
|
||||
void OnMouseMiddleUp(wxMouseEvent& evt);
|
||||
void OnContextMenu(wxContextMenuEvent& evt);
|
||||
void OnMouseWheel(wxMouseEvent& evt);
|
||||
void OnChar(wxKeyEvent& evt);
|
||||
|
Reference in New Issue
Block a user