Implement wxWindow::Disable() for non-native controls in wxOSX.

Previously disabling generic window simply didn't do anything.

Fix this by explicitly refusing to generate mouse/keyboard events for it.

Closes #13155.
This commit is contained in:
Steve Browne
2015-03-12 13:37:17 +01:00
committed by Vadim Zeitlin
parent 009abf22b7
commit 7f0963dcf7
2 changed files with 16 additions and 0 deletions

View File

@@ -142,6 +142,7 @@ wxMSW:
wxOSX/Cocoa:
- Implement wxWindow::Disable() for non-native controls too (Steve Browne).
- Add support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP
events (Igor Korot).
- Implement strike-through support in wxFont (Igor Korot).

View File

@@ -877,6 +877,15 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
return NO;
}
- (NSView *)hitTest:(NSPoint)aPoint;
{
wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if ( viewimpl && viewimpl->GetWXPeer() && !viewimpl->GetWXPeer()->IsEnabled() )
return nil;
return [super hitTest:aPoint];
}
@end // wxNSView
// We need to adopt NSTextInputClient protocol in order to interpretKeyEvents: to work.
@@ -1381,6 +1390,9 @@ bool wxWidgetCocoaImpl::SetupCursor(WX_NSEvent event)
void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
{
if ( !m_wxPeer->IsEnabled() )
return;
if ( [event type] == NSKeyDown )
{
// there are key equivalents that are not command-combos and therefore not handled by cocoa automatically,
@@ -2593,6 +2605,9 @@ void wxWidgetCocoaImpl::Enable( bool enable )
if ( [targetView respondsToSelector:@selector(setEnabled:) ] )
[targetView setEnabled:enable];
if ( !enable && HasFocus() )
m_wxPeer->Navigate();
}
void wxWidgetCocoaImpl::PulseGauge()