From: Kevin Ollivier Date: Sat, 27 Feb 2010 02:51:45 +0000 (+0000) Subject: Override CanFocus because the wxWindow level test will check if the NSTextView's... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/78a17075019ea5bed5085d3afeb822c47d77a82c Override CanFocus because the wxWindow level test will check if the NSTextView's parent scrollview can get keyboard focus, and will return no, meaning that wx won't set the focus to the text ctrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63564 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index 77d6f366b9..21a60a40c9 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -63,6 +63,8 @@ public: virtual bool GetStyle(long position, wxTextAttr& style); virtual void SetStyle(long start, long end, const wxTextAttr& style); + virtual bool CanFocus() const; + virtual bool HasOwnContextMenu() const { return true; } virtual void CheckSpelling(bool check); diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 1f10089116..d5af7b488c 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -229,7 +229,6 @@ protected : return fieldEditor; } - - (void) setEnabled:(BOOL) flag { [super setEnabled: flag]; @@ -322,6 +321,15 @@ wxNSTextViewControl::~wxNSTextViewControl() [m_textView setDelegate: nil]; } +bool wxNSTextViewControl::CanFocus() const +{ + // we need to override so that we don't return the CanFocus value of + // the text view's overriding scroll view. + if (m_textView) + return [m_textView canBecomeKeyView]; + return false; +} + wxString wxNSTextViewControl::GetStringValue() const { if (m_textView) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index a2aea90d23..a5148d5ee3 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1644,7 +1644,7 @@ bool wxWidgetCocoaImpl::HasFocus() const bool wxWidgetCocoaImpl::SetFocus() { - if ( [m_osxView canBecomeKeyView] == NO ) + if ( !CanFocus() ) return false; [[m_osxView window] makeFirstResponder: m_osxView] ;