X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ec1179b86dac6c87ad9f2cd126f87e92642c62c..95f82f4ce3ad30120b6831a3df057a5f486999ea:/src/common/textentrycmn.cpp?ds=sidebyside diff --git a/src/common/textentrycmn.cpp b/src/common/textentrycmn.cpp index 67443dcdad..5ec6850708 100644 --- a/src/common/textentrycmn.cpp +++ b/src/common/textentrycmn.cpp @@ -26,9 +26,12 @@ #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX #ifndef WX_PRECOMP + #include "wx/window.h" + #include "wx/dataobj.h" #endif //WX_PRECOMP #include "wx/textentry.h" +#include "wx/clipbrd.h" // ============================================================================ // wxTextEntryBase implementation @@ -37,7 +40,9 @@ wxString wxTextEntryBase::GetRange(long from, long to) const { wxString sel; - if ( from < to ) + wxString value = GetValue(); + + if ((from < to) && ((long)value.length() >= to + from)) { sel = GetValue().substr(from, to - from); } @@ -77,6 +82,14 @@ bool wxTextEntryBase::HasSelection() const return from < to; } +void wxTextEntryBase::RemoveSelection() +{ + long from, to; + GetSelection(& from, & to); + if (from != -1 && to != -1) + Remove(from, to); +} + wxString wxTextEntryBase::GetStringSelection() const { long from, to; @@ -97,7 +110,22 @@ bool wxTextEntryBase::CanCut() const bool wxTextEntryBase::CanPaste() const { - return IsEditable(); + if ( IsEditable() ) + { +#if wxUSE_CLIPBOARD + // check if there is any text on the clipboard + if ( wxTheClipboard->IsSupported(wxDF_TEXT) +#if wxUSE_UNICODE + || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) +#endif // wxUSE_UNICODE + ) + { + return true; + } +#endif // wxUSE_CLIPBOARD + } + + return false; } #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX