]> git.saurik.com Git - wxWidgets.git/commitdiff
fixing setting initial value under osx_cocoa for single line text controls
authorStefan Csomor <csomor@advancedconcepts.ch>
Thu, 1 Oct 2009 08:59:01 +0000 (08:59 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Thu, 1 Oct 2009 08:59:01 +0000 (08:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/textctrl.mm
src/osx/textctrl_osx.cpp

index 13b2d9789769abd3fe80293cbd76120c557e70ed..2c91b8bc273ad330a84d536e67fc3548220d4f3e 100644 (file)
@@ -59,7 +59,8 @@ class wxMacEditHelper
 public :
     wxMacEditHelper( NSView* textView )
     {
 public :
     wxMacEditHelper( NSView* textView )
     {
-        m_textView = textView ;
+        m_textView = textView;
+        m_formerState = YES;
         if ( textView )
         {
             m_formerState = [textView isEditable];
         if ( textView )
         {
             m_formerState = [textView isEditable];
@@ -422,7 +423,7 @@ void wxNSTextViewControl::WriteText(const wxString& str)
     m_lastKeyDownEvent = formerEvent;
 }
 
     m_lastKeyDownEvent = formerEvent;
 }
 
-void wxNSTextViewControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack )
+void wxNSTextViewControl::SetFont( const wxFont & font , const wxColour& WXUNUSED(foreground) , long WXUNUSED(windowStyle), bool WXUNUSED(ignoreBlack) )
 {
     if ([m_textView respondsToSelector:@selector(setFont:)])
         [m_textView setFont: font.OSXGetNSFont()];
 {
     if ([m_textView respondsToSelector:@selector(setFont:)])
         [m_textView setFont: font.OSXGetNSFont()];
@@ -581,7 +582,7 @@ void wxNSTextFieldControl::controlAction(WXWidget WXUNUSED(slf),
 wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
                                     wxWindowMac* WXUNUSED(parent),
                                     wxWindowID WXUNUSED(id),
 wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
                                     wxWindowMac* WXUNUSED(parent),
                                     wxWindowID WXUNUSED(id),
-                                    const wxString& str,
+                                    const wxString& WXUNUSED(str),
                                     const wxPoint& pos,
                                     const wxSize& size,
                                     long style,
                                     const wxPoint& pos,
                                     const wxSize& size,
                                     long style,
@@ -595,7 +596,6 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
         wxNSTextScrollView* v = nil;
         v = [[wxNSTextScrollView alloc] initWithFrame:r];
         c = new wxNSTextViewControl( wxpeer, v );
         wxNSTextScrollView* v = nil;
         v = [[wxNSTextScrollView alloc] initWithFrame:r];
         c = new wxNSTextViewControl( wxpeer, v );
-        static_cast<wxNSTextViewControl*>(c)->SetStringValue(str);
     }
     else
     {
     }
     else
     {
@@ -615,7 +615,6 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
         [v setBordered:NO];
 
         c = new wxNSTextFieldControl( wxpeer, v );
         [v setBordered:NO];
 
         c = new wxNSTextFieldControl( wxpeer, v );
-        static_cast<wxNSTextFieldControl*>(c)->SetStringValue(str);
     }
 
     return c;
     }
 
     return c;
index 8fd25ac960ba0a6d19615e95d515e7a0bdf99de2..1ff3094dbc4d7c49ecec37b518bc5d5c23097642 100644 (file)
@@ -119,7 +119,13 @@ bool wxTextCtrl::Create( wxWindow *parent,
     m_peer = wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() );
 
     MacPostControlCreate(pos, size) ;
     m_peer = wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() );
 
     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() ;
     // only now the embedding is correct and we can do a positioning update
 
     MacSuperChangedPosition() ;