X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8b204e6fd541515bead44e1be86ab8cb44a35d3..780bb8744b5a9d9492831f0bd338251aa4641c56:/src/msw/textctrl.cpp?ds=sidebyside diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index bc78ce19b0..a6686ae562 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -648,6 +648,34 @@ void wxTextCtrl::GetSelection(long* from, long* to) const } } +wxString wxTextCtrl::GetStringSelection() const +{ + // the base class version works correctly for the rich text controls + // because there the lines are terminated with just '\r' which means that + // the string length is not changed in the result of the translations doen + // in GetValue() but for the normal ones when we replace "\r\n" with '\n' + // we break the indices +#if wxUSE_RICHEDIT + if ( m_isRich ) + return wxTextCtrlBase::GetStringSelection(); +#endif // wxUSE_RICHEDIT + + long from, to; + GetSelection(&from, &to); + + wxString str; + if ( from < to ) + { + str = wxGetWindowText(GetHWND()).Mid(from, to - from); + + // and now that we have the correct selection, convert it to the + // correct format + str = wxTextFile::Translate(str, wxTextFileType_Unix); + } + + return str; +} + bool wxTextCtrl::IsEditable() const { long style = ::GetWindowLong(GetHwnd(), GWL_STYLE);