From: Julian Smart Date: Thu, 15 Dec 2011 11:32:58 +0000 (+0000) Subject: Applied #13763 from dghart, to use primary selections if available X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5dec941a5ba3c08870ab4b415dd6e5be368fa0f0 Applied #13763 from dghart, to use primary selections if available git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70011 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 466dc88569..0e1c0c1ed8 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -35,6 +35,16 @@ #include "wx/fontenum.h" #include "wx/accel.h" +#if defined (__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) +#define wxHAVE_PRIMARY_SELECTION 1 +#else +#define wxHAVE_PRIMARY_SELECTION 0 +#endif + +#if wxUSE_CLIPBOARD && wxHAVE_PRIMARY_SELECTION +#include "wx/clipbrd.h" +#endif + // DLL options compatibility check: #include "wx/app.h" WX_CHECK_BUILD_OPTIONS("wxRichTextCtrl") @@ -639,6 +649,19 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) } } } + +#if wxUSE_CLIPBOARD && wxUSE_DATAOBJ && wxHAVE_PRIMARY_SELECTION + if (HasSelection() && GetFocusObject() && GetFocusObject()->GetBuffer()) + { + // Put the selection in PRIMARY, if it exists + wxTheClipboard->UsePrimarySelection(true); + + wxRichTextRange range = GetInternalSelectionRange(); + GetFocusObject()->GetBuffer()->CopyToClipboard(range); + + wxTheClipboard->UsePrimarySelection(false); + } +#endif } /// Left-click @@ -839,6 +862,13 @@ void wxRichTextCtrl::OnMiddleClick(wxMouseEvent& event) if (!GetEventHandler()->ProcessEvent(cmdEvent)) event.Skip(); + +#if wxUSE_CLIPBOARD && wxUSE_DATAOBJ && wxHAVE_PRIMARY_SELECTION + // Paste any PRIMARY selection, if it exists + wxTheClipboard->UsePrimarySelection(true); + Paste(); + wxTheClipboard->UsePrimarySelection(false); +#endif } /// Key press