adding support for focus events to multiline textctrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-03-25 13:12:55 +00:00
parent 2e6c4a5702
commit 1087c6c1c6

View File

@@ -94,13 +94,22 @@
@end @end
@interface wxNSTextView : NSScrollView @interface wxNSTextScrollView : NSScrollView
{ {
} }
@end
@interface wxNSTextView : NSTextView
{
wxNSTextScrollView* scrollView;
}
- (void)setScrollView: (wxNSTextScrollView *) sv;
- (wxNSTextScrollView*) scrollView;
@end @end
@implementation wxNSTextView @implementation wxNSTextScrollView
+ (void)initialize + (void)initialize
{ {
@@ -149,6 +158,44 @@
return NO; 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 @end
@implementation wxNSTextField @implementation wxNSTextField
@@ -235,22 +282,25 @@ typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl
wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) 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 setHasVerticalScroller:YES];
[m_scrollView setHasHorizontalScroller:NO]; [m_scrollView setHasHorizontalScroller:NO];
[m_scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [m_scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
NSSize contentSize = [m_scrollView contentSize]; 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)]; contentSize.width, contentSize.height)];
[m_textView setVerticallyResizable:YES]; m_textView = tv;
[m_textView setHorizontallyResizable:NO]; [tv setVerticallyResizable:YES];
[m_textView setAutoresizingMask:NSViewWidthSizable]; [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() wxNSTextViewControl::~wxNSTextViewControl()
@@ -447,8 +497,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
if ( style & wxTE_MULTILINE || style & wxTE_RICH || style & wxTE_RICH2 ) if ( style & wxTE_MULTILINE || style & wxTE_RICH || style & wxTE_RICH2 )
{ {
wxNSTextView* v = nil; wxNSTextScrollView* v = nil;
v = [[wxNSTextView alloc] initWithFrame:r]; v = [[wxNSTextScrollView alloc] initWithFrame:r];
c = new wxNSTextViewControl( wxpeer, v ); c = new wxNSTextViewControl( wxpeer, v );
static_cast<wxNSTextViewControl*>(c)->SetStringValue(str); static_cast<wxNSTextViewControl*>(c)->SetStringValue(str);
} }