X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6331c8c0216d220618e2f3017c59db1e2fd56a29..ee032c59df7ac4facdfdffce016768ab858e18c0:/src/osx/cocoa/textctrl.mm diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 8ad2937d97..ca728cf9db 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -82,15 +82,34 @@ } } +- (void)controlTextDidEndEditing:(NSNotification *)aNotification +{ + wxUnusedVar(aNotification); + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + if ( impl ) + { + impl->DoNotifyFocusEvent( false, NULL ); + } +} + +@end + +@interface wxNSTextScrollView : NSScrollView +{ +} @end -@interface wxNSTextView : NSScrollView +@interface wxNSTextView : NSTextView { + wxNSTextScrollView* scrollView; } +- (void)setScrollView: (wxNSTextScrollView *) sv; +- (wxNSTextScrollView*) scrollView; + @end -@implementation wxNSTextView +@implementation wxNSTextScrollView + (void)initialize { @@ -139,6 +158,44 @@ return NO; } + +- (void)textDidEndEditing:(NSNotification *)aNotification +{ + wxUnusedVar(aNotification); + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + if ( impl ) + { + impl->DoNotifyFocusEvent( false, NULL ); + } +} +@end + +@implementation wxNSTextView + +- (BOOL) becomeFirstResponder +{ + BOOL val = [super becomeFirstResponder]; + + if ( val ) + { + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( scrollView ); + if (impl ) + impl->DoNotifyFocusEvent( true, NULL ); + + } + return val; +} + +- (void)setScrollView: (wxNSTextScrollView *) sv +{ + scrollView = sv; +} + +- (wxNSTextScrollView*) scrollView +{ + return scrollView; +} + @end @implementation wxNSTextField @@ -209,43 +266,41 @@ typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl return NO; } -/* + - (void)controlTextDidEndEditing:(NSNotification *)aNotification { + wxUnusedVar(aNotification); + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl ) { - wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); - if ( wxpeer ) { - wxFocusEvent event(wxEVT_KILL_FOCUS, wxpeer->GetId()); - event.SetEventObject( wxpeer ); - event.SetWindow( wxpeer ); - wxpeer->HandleWindowEvent( event ); - } + impl->DoNotifyFocusEvent( false, NULL ); } } -*/ @end // wxNSTextViewControl wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) { - m_scrollView = (NSScrollView*) w; + wxNSTextScrollView* sv = (wxNSTextScrollView*) w; + m_scrollView = sv; [m_scrollView setHasVerticalScroller:YES]; [m_scrollView setHasHorizontalScroller:NO]; [m_scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; NSSize contentSize = [m_scrollView contentSize]; - m_textView = [[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, + wxNSTextView* tv = [[wxNSTextView alloc] initWithFrame: NSMakeRect(0, 0, contentSize.width, contentSize.height)]; - [m_textView setVerticallyResizable:YES]; - [m_textView setHorizontallyResizable:NO]; - [m_textView setAutoresizingMask:NSViewWidthSizable]; + m_textView = tv; + [tv setVerticallyResizable:YES]; + [tv setHorizontallyResizable:NO]; + [tv setAutoresizingMask:NSViewWidthSizable]; - [m_scrollView setDocumentView: m_textView]; + [m_scrollView setDocumentView: tv]; - [m_textView setDelegate: w]; + [tv setDelegate: w]; + [tv setScrollView:sv]; } wxNSTextViewControl::~wxNSTextViewControl() @@ -442,8 +497,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, if ( style & wxTE_MULTILINE || style & wxTE_RICH || style & wxTE_RICH2 ) { - wxNSTextView* v = nil; - v = [[wxNSTextView alloc] initWithFrame:r]; + wxNSTextScrollView* v = nil; + v = [[wxNSTextScrollView alloc] initWithFrame:r]; c = new wxNSTextViewControl( wxpeer, v ); static_cast(c)->SetStringValue(str); }