X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa2f57be4db838388659fe48dbf5546daf5364f8..33ddeabab99a7895d7763390f3761c5ccb1f094c:/src/common/textentrycmn.cpp?ds=sidebyside diff --git a/src/common/textentrycmn.cpp b/src/common/textentrycmn.cpp index 956d5d5914..5ec6850708 100644 --- a/src/common/textentrycmn.cpp +++ b/src/common/textentrycmn.cpp @@ -26,6 +26,8 @@ #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX #ifndef WX_PRECOMP + #include "wx/window.h" + #include "wx/dataobj.h" #endif //WX_PRECOMP #include "wx/textentry.h" @@ -38,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); } @@ -78,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; @@ -102,8 +114,14 @@ bool wxTextEntryBase::CanPaste() const { #if wxUSE_CLIPBOARD // check if there is any text on the clipboard - if ( wxTheClipboard->IsSupported(wxDF_TEXT) ) + if ( wxTheClipboard->IsSupported(wxDF_TEXT) +#if wxUSE_UNICODE + || wxTheClipboard->IsSupported(wxDF_UNICODETEXT) +#endif // wxUSE_UNICODE + ) + { return true; + } #endif // wxUSE_CLIPBOARD }