Set initial wxTextCtrl text earlier in wxOSX
This reverts the changes of63bcc669d8
(fixing setting initial value under osx_cocoa for single line text controls, 2009-10-01) and fixes the problem which this commit probably tried to fix in a different way, using the same approach as in98f5315405
(Don't set initial label in wxNativeWindow on OS X, 2016-04-29) as the real root of the problem was that the text set in CreateTextControl() was overwritten later when the label was set from SetPeer(). This change means that the text is now set correctly before SetPeer() calls SetInitialSize() call, which makes it possible to set the correct initial size based on the initial text, as will be done in later commits. It also makes Cocoa port more consistent with iOS one, as a nice side effect.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user