+@interface NSView(EditableView)
+- (BOOL)isEditable;
+- (void)setEditable:(BOOL)flag;
+@end
+
+class wxMacEditHelper
+{
+public :
+ wxMacEditHelper( NSView* textView )
+ {
+ m_textView = textView;
+ m_formerState = YES;
+ if ( textView )
+ {
+ m_formerState = [textView isEditable];
+ [textView setEditable:YES];
+ }
+ }
+
+ ~wxMacEditHelper()
+ {
+ if ( m_textView )
+ [m_textView setEditable:m_formerState];
+ }
+
+protected :
+ BOOL m_formerState ;
+ NSView* m_textView;
+} ;
+
+@implementation wxNSSecureTextField
+
++ (void)initialize
+{
+ static BOOL initialized = NO;
+ if (!initialized)
+ {
+ initialized = YES;
+ wxOSXCocoaClassAddWXMethods( self );
+ }
+}
+
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+
+- (void)controlTextDidEndEditing:(NSNotification *)aNotification
+{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ impl->DoNotifyFocusEvent( false, NULL );
+ }
+}
+
+@end
+
+@interface wxNSTextScrollView : NSScrollView
+{
+}
+@end
+
+@implementation wxNSTextScrollView
+
++ (void)initialize
+{
+ static BOOL initialized = NO;
+ if (!initialized)
+ {
+ initialized = YES;
+ wxOSXCocoaClassAddWXMethods( self );
+ }
+}
+
+@end
+
+@implementation wxNSTextFieldEditor
+
+- (void) keyDown:(NSEvent*) event
+{
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
+ lastKeyDownEvent = event;
+ if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
+ [super keyDown:event];
+ lastKeyDownEvent = nil;
+}
+
+- (void) keyUp:(NSEvent*) event
+{
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
+ if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
+ [super keyUp:event];
+}
+
+- (void) flagsChanged:(NSEvent*) event
+{
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
+ if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
+ [super flagsChanged:event];
+}
+
+- (BOOL) performKeyEquivalent:(NSEvent*) event
+{
+ BOOL retval = [super performKeyEquivalent:event];
+ return retval;
+}
+
+- (void) insertText:(id) str
+{
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
+ if ( impl == NULL || lastKeyDownEvent==nil || !impl->DoHandleCharEvent(lastKeyDownEvent, str) )
+ {
+ [super insertText:str];
+ }
+}
+
+@end
+
+@implementation wxNSTextView
+
++ (void)initialize
+{
+ static BOOL initialized = NO;
+ if (!initialized)
+ {
+ initialized = YES;
+ wxOSXCocoaClassAddWXMethods( self );
+ }
+}
+
+- (void)textDidChange:(NSNotification *)aNotification
+{
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( [aNotification object] );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+
+@end
+