Allow wxDataViewCtrl to gain focus in wxOSX
Fix numerous focus-handling bugs in wxOSX in combination with NSScrollView (which cannot get focus by itself and which was already treated specially in many, but not all, places), including - inability to set the focus - loss of wxEVT_SET_FOCUS events - loss of wxWindow<->NSView association after clearing wxDVC columns
This commit is contained in:
parent
f3b8dac3b7
commit
73f6bf7b6f
@ -1915,6 +1915,14 @@ outlineView:(NSOutlineView*)outlineView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL) becomeFirstResponder
|
||||||
|
{
|
||||||
|
BOOL r = [super becomeFirstResponder];
|
||||||
|
if ( r )
|
||||||
|
implementation->DoNotifyFocusSet();
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@ -1942,15 +1950,16 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer,
|
|||||||
[scrollview setAutohidesScrollers:YES];
|
[scrollview setAutohidesScrollers:YES];
|
||||||
[scrollview setDocumentView:m_OutlineView];
|
[scrollview setDocumentView:m_OutlineView];
|
||||||
|
|
||||||
// we cannot call InstallHandler(m_OutlineView) here, because we are handling
|
|
||||||
// our action:s ourselves, only associate the view with this impl
|
|
||||||
Associate(m_OutlineView,this);
|
|
||||||
// initialize the native control itself too
|
// initialize the native control itself too
|
||||||
InitOutlineView(style);
|
InitOutlineView(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCocoaDataViewControl::InitOutlineView(long style)
|
void wxCocoaDataViewControl::InitOutlineView(long style)
|
||||||
{
|
{
|
||||||
|
// we cannot call InstallHandler(m_OutlineView) here, because we are handling
|
||||||
|
// our action:s ourselves, only associate the view with this impl
|
||||||
|
Associate(m_OutlineView,this);
|
||||||
|
|
||||||
[m_OutlineView setImplementation:this];
|
[m_OutlineView setImplementation:this];
|
||||||
[m_OutlineView setFocusRingType:NSFocusRingTypeNone];
|
[m_OutlineView setFocusRingType:NSFocusRingTypeNone];
|
||||||
[m_OutlineView setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
[m_OutlineView setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
||||||
|
@ -2328,12 +2328,18 @@ bool wxWidgetCocoaImpl::GetNeedsDisplay() const
|
|||||||
|
|
||||||
bool wxWidgetCocoaImpl::CanFocus() const
|
bool wxWidgetCocoaImpl::CanFocus() const
|
||||||
{
|
{
|
||||||
return [m_osxView canBecomeKeyView] == YES;
|
NSView* targetView = m_osxView;
|
||||||
|
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||||
|
targetView = [(NSScrollView*) m_osxView documentView];
|
||||||
|
return [targetView canBecomeKeyView] == YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::HasFocus() const
|
bool wxWidgetCocoaImpl::HasFocus() const
|
||||||
{
|
{
|
||||||
return ( FindFocus() == m_osxView );
|
NSView* targetView = m_osxView;
|
||||||
|
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||||
|
targetView = [(NSScrollView*) m_osxView documentView];
|
||||||
|
return ( FindFocus() == targetView );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::SetFocus()
|
bool wxWidgetCocoaImpl::SetFocus()
|
||||||
@ -2341,6 +2347,10 @@ bool wxWidgetCocoaImpl::SetFocus()
|
|||||||
if ( !CanFocus() )
|
if ( !CanFocus() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
NSView* targetView = m_osxView;
|
||||||
|
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||||
|
targetView = [(NSScrollView*) m_osxView documentView];
|
||||||
|
|
||||||
// TODO remove if no issues arise: should not raise the window, only assign focus
|
// TODO remove if no issues arise: should not raise the window, only assign focus
|
||||||
//[[m_osxView window] makeKeyAndOrderFront:nil] ;
|
//[[m_osxView window] makeKeyAndOrderFront:nil] ;
|
||||||
[[m_osxView window] makeFirstResponder: m_osxView] ;
|
[[m_osxView window] makeFirstResponder: m_osxView] ;
|
||||||
|
Loading…
Reference in New Issue
Block a user