+@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 )
+ impl->controlTextDidChange();
+}
+
+- (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
+{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ impl->controlTextDidChange();
+}
+
+@end
+