From: Vadim Zeitlin Date: Sat, 15 Mar 2008 02:58:54 +0000 (+0000) Subject: refactored code reused in several different places in wxTextEntry::RemoveSelection... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5a25f8581a6e11d4a7d61d40434a826a1a228d53 refactored code reused in several different places in wxTextEntry::RemoveSelection() (patch 1910166) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/textentry.h b/include/wx/textentry.h index 8567296cba..32c6895bd5 100644 --- a/include/wx/textentry.h +++ b/include/wx/textentry.h @@ -54,6 +54,7 @@ public: virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to) = 0; virtual void Clear() { SetValue(wxString()); } + void RemoveSelection(); // clipboard operations diff --git a/src/common/textentrycmn.cpp b/src/common/textentrycmn.cpp index 61d80ffbaa..c6b769601e 100644 --- a/src/common/textentrycmn.cpp +++ b/src/common/textentrycmn.cpp @@ -80,6 +80,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; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 3e3429f1fa..0ad836e685 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -493,10 +493,7 @@ void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event)) void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event)) { - long from, to; - GetSelection(& from, & to); - if (from != -1 && to != -1) - Remove(from, to); + RemoveSelection(); } void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event)) diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 2de9a4e10b..9d8e4a542d 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -581,10 +581,7 @@ void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event)) void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event)) { - long from, to; - GetSelection(& from, & to); - if (from != -1 && to != -1) - Remove(from, to); + RemoveSelection(); } void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event)) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index b6144e1fbf..5007bc1d84 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2064,10 +2064,7 @@ void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event)) void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event)) { - long from, to; - GetSelection(& from, & to); - if (from != -1 && to != -1) - Remove(from, to); + RemoveSelection(); } void wxTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))