diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index fc44aeb15d..b0e19367b0 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -32,6 +32,12 @@ public : virtual ~wxNSTextBase() { } virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const wxOVERRIDE; + + virtual void SetInitialLabel(const wxString& WXUNUSED(title), wxFontEncoding WXUNUSED(encoding)) wxOVERRIDE + { + // Don't do anything here, text controls don't have any label and + // setting it would overwrite the string value set when creating it. + } }; // implementation exposed, so that search control can pull it diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index d4d18a5200..da72115bea 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -1556,7 +1556,7 @@ void wxNSTextFieldControl::SetJustification() wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), - const wxString& WXUNUSED(str), + const wxString& str, const wxPoint& pos, const wxSize& size, long style, @@ -1569,8 +1569,11 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, { wxNSTextScrollView* v = nil; v = [[wxNSTextScrollView alloc] initWithFrame:r]; - c = new wxNSTextViewControl( wxpeer, v, style ); + wxNSTextViewControl* t = new wxNSTextViewControl( wxpeer, v, style ); + c = t; c->SetNeedsFocusRect( true ); + + t->SetStringValue(str); } else { @@ -1593,7 +1596,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, [cell setWraps:NO]; [cell setScrollable:YES]; - c = new wxNSTextFieldControl( wxpeer, wxpeer, v ); + wxNSTextFieldControl* t = new wxNSTextFieldControl( wxpeer, wxpeer, v ); + c = t; if ( (style & wxNO_BORDER) || (style & wxSIMPLE_BORDER) ) { @@ -1608,6 +1612,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, // use native border c->SetNeedsFrame(false); } + + t->SetStringValue(str); } return c; diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 4e64b8c530..71c7bb62ba 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -105,12 +105,6 @@ bool wxTextCtrl::Create( wxWindow *parent, MacPostControlCreate(pos, size) ; -#if wxOSX_USE_COCOA - // under carbon everything can already be set before the MacPostControlCreate embedding takes place - // but under cocoa for single line textfields this only works after everything has been set up - GetTextPeer()->SetStringValue(str); -#endif - // only now the embedding is correct and we can do a positioning update MacSuperChangedPosition() ;