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)