From: Vadim Zeitlin Date: Thu, 18 Apr 2002 23:32:41 +0000 (+0000) Subject: select the whole text in the single line text control when its SetFocus() is called... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/129223d68ed841d3c3265fe31c70877e0bc685ac select the whole text in the single line text control when its SetFocus() is called (which also happens when the user TABs to it) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15203 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index c5e03295f3..07fa37fe8b 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -128,6 +128,7 @@ public: // Implementation from now on // -------------------------- + virtual void SetFocus(); virtual void SetWindowStyleFlag(long style); virtual void Command(wxCommandEvent& event); diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index a5acb508d2..1a0b6c5f40 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1244,6 +1244,24 @@ long wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) return wxTextCtrlBase::MSWWindowProc(nMsg, wParam, lParam); } +void wxTextCtrl::SetFocus() +{ + wxTextCtrlBase::SetFocus(); + + // to be consistent with the standard Windows behaviour we select all text + // in the single line edit controls when the user TABs to them and also, to + // be consistent with this behaviour in turn, do it whenever SetFocus() is + // called as well + if ( !HasFlag(wxTE_MULTILINE) ) + { + SetSelection(-1, -1); + } +} + +// ---------------------------------------------------------------------------- +// text control event processing +// ---------------------------------------------------------------------------- + bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { switch (param)