- // temp hack to get logging working early
- wxString former = GetStringValue();
- SetStringValue( former + str );
- SetSelection(GetStringValue().length(), GetStringValue().length());
+ NSText* editor = [m_textField currentEditor];
+ if ( editor )
+ {
+ wxMacEditHelper helper(m_textField);
+ [editor insertText:wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
+ }
+ else
+ {
+ wxString val = GetStringValue() ;
+ long start , end ;
+ GetSelection( &start , &end ) ;
+ val.Remove( start , end - start ) ;
+ val.insert( start , str ) ;
+ SetStringValue( val ) ;
+ SetSelection( start + str.length() , start + str.length() ) ;
+ }