diff --git a/docs/changes.txt b/docs/changes.txt index 08de5a3c70..42f60e8942 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -176,6 +176,7 @@ All (GUI): - Add wxFontPickerCtrl::SetMinPointSize() (Andreas Falkenhahn). - Add Set/GetFooter/Text/Icon() to wxRichMessageDialog (Tobias Taschner) - Add wxFloatingPointValidator::SetFactor(). +- Add "hint" property to wxSearchCtrl XRC handler. wxGTK: diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 75a9f54815..92cea1ff7c 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -1950,6 +1950,9 @@ child and the second one for right/bottom child window. @hdr3col{property, type, description} @row3col{value, @ref overview_xrcformat_type_text, Initial value of the control (default: empty).} +@row3col{hint, @ref overview_xrcformat_type_text, + Descriptive text shown in the empty control (default: "Search"). This + property is new since wxWidgets 3.1.1.} @endTable diff --git a/include/wx/generic/srchctlg.h b/include/wx/generic/srchctlg.h index a3d0ce86fe..ebcae90e78 100644 --- a/include/wx/generic/srchctlg.h +++ b/include/wx/generic/srchctlg.h @@ -61,9 +61,8 @@ public: virtual void ShowCancelButton( bool show ) wxOVERRIDE; virtual bool IsCancelButtonVisible() const wxOVERRIDE; - // TODO: In 2.9 these should probably be virtual, and declared in the base class... - void SetDescriptiveText(const wxString& text); - wxString GetDescriptiveText() const; + virtual void SetDescriptiveText(const wxString& text) wxOVERRIDE; + virtual wxString GetDescriptiveText() const wxOVERRIDE; // accessors // --------- diff --git a/include/wx/osx/srchctrl.h b/include/wx/osx/srchctrl.h index 4a4d88af47..2bef62b75e 100644 --- a/include/wx/osx/srchctrl.h +++ b/include/wx/osx/srchctrl.h @@ -54,9 +54,8 @@ public: virtual void ShowCancelButton( bool show ) wxOVERRIDE; virtual bool IsCancelButtonVisible() const wxOVERRIDE; - // TODO: In 2.9 these should probably be virtual, and declared in the base class... - void SetDescriptiveText(const wxString& text); - wxString GetDescriptiveText() const; + virtual void SetDescriptiveText(const wxString& text) wxOVERRIDE; + virtual wxString GetDescriptiveText() const wxOVERRIDE; virtual bool HandleSearchFieldSearchHit() ; virtual bool HandleSearchFieldCancelHit() ; diff --git a/include/wx/srchctrl.h b/include/wx/srchctrl.h index b28d3912d1..791fcb8092 100644 --- a/include/wx/srchctrl.h +++ b/include/wx/srchctrl.h @@ -68,6 +68,9 @@ public: virtual void ShowCancelButton( bool show ) = 0; virtual bool IsCancelButtonVisible() const = 0; + virtual void SetDescriptiveText(const wxString& text) = 0; + virtual wxString GetDescriptiveText() const = 0; + private: // implement wxTextEntry pure virtual method virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; } diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 9264d8def9..5ad5654fe4 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -49,7 +49,7 @@ class wxSearchTextCtrl : public wxTextCtrl public: wxSearchTextCtrl(wxSearchCtrl *search, const wxString& value, int style) : wxTextCtrl(search, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, - (style & ~wxBORDER_MASK) | wxNO_BORDER) + (style & ~wxBORDER_MASK) | wxNO_BORDER | wxTE_PROCESS_ENTER) { m_search = search; diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 2f7bc4d21a..686435b620 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2078,7 +2078,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // forces at the moment unfortunately if ( !(m_windowStyle & wxTE_PROCESS_TAB)) { - if ( FindFocus() == this ) + if ( ::GetFocus() == GetHwnd() ) { int flags = 0; if (!event.ShiftDown()) diff --git a/src/xrc/xh_srchctrl.cpp b/src/xrc/xh_srchctrl.cpp index dbaafdedde..122d38cfbc 100644 --- a/src/xrc/xh_srchctrl.cpp +++ b/src/xrc/xh_srchctrl.cpp @@ -49,6 +49,10 @@ wxObject *wxSearchCtrlXmlHandler::DoCreateResource() SetupWindow(ctrl); + const wxString& hint = GetText(wxS("hint")); + if ( !hint.empty() ) + ctrl->SetDescriptiveText(hint); + return ctrl; }