Try to improve CanFocus() behaviour for hidden windows
This should be less important now that we don't rely on CanFocus() to determine if we should set focus to the window any longer, but it seems to still be better to try to make it work better for hidden windows, so at least return true from it when full keyboard access is on. When it's off, the behaviour is the same as before, but this doesn't affect wxTextCtrl, whose peer NSView overrides CanFocus() to always return true. We almost certainly need to override CanFocus() in other views, notably wxDataViewCtrl, wxSearchCtrl, and any other controls that can have focus even when full keyboard access is off. See #17340.
This commit is contained in:
@@ -3090,6 +3090,16 @@ bool wxWidgetCocoaImpl::GetNeedsDisplay() const
|
||||
|
||||
bool wxWidgetCocoaImpl::CanFocus() const
|
||||
{
|
||||
if ( !IsVisible() )
|
||||
{
|
||||
// It's useless to call canBecomeKeyView in this case, it will always
|
||||
// return false. Try to return something reasonable ourselves, knowing
|
||||
// that most controls are not focusable when full keyboard access if
|
||||
// off and wxNSTextViewControl overrides CanFocus() to always return
|
||||
// true anyhow.
|
||||
return [NSApp isFullKeyboardAccessEnabled];
|
||||
}
|
||||
|
||||
NSView* targetView = m_osxView;
|
||||
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||
targetView = [(NSScrollView*) m_osxView documentView];
|
||||
|
Reference in New Issue
Block a user