]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/textctrl_osx.cpp
Create an autorelease pool to catch objects created during several special situations...
[wxWidgets.git] / src / osx / textctrl_osx.cpp
index 29546c39cbb31ce414f725e474eedcdf9f7b1d1c..6edd282e97b83ec4339ba51db7a97f455252569d 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) ;
-
+    
+#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() ;
@@ -367,6 +373,11 @@ wxSize wxTextCtrl::DoGetBestSize() const
     return wxSize(wText, hText);
 }
 
+bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
+{
+    return GetTextPeer()->GetStyle(position, style);
+}
+
 // ----------------------------------------------------------------------------
 // Undo/redo
 // ----------------------------------------------------------------------------
@@ -473,7 +484,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
         return ;
     }
 
-    if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
+    if ( !IsEditable() && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) &&
         !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
 //        && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
         )
@@ -486,8 +497,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
     // allow navigation and deletion
     GetSelection( &from, &to );
     if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
-        key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB && key != WXK_UP && key != WXK_DOWN &&
-        key != WXK_BACK && key != WXK_DELETE && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) &&
+        !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) &&
+        !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) &&
         from == to )
     {
         // eat it, we don't want to add more than allowed # of characters
@@ -718,6 +729,12 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
 // implementation base class
 // ----------------------------------------------------------------------------
 
+bool wxTextWidgetImpl::GetStyle(long WXUNUSED(position),
+                                wxTextAttr& WXUNUSED(style))
+{
+    return false;
+}
+
 void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
                                 long WXUNUSED(end),
                                 const wxTextAttr& WXUNUSED(style))