separate non-native key handling from IsUserPane
NSOpenGLView is needed under 10.14 as a native view, but it doesn’t have its own native key handling, therefore use the same code we have for non-native custom views.
This commit is contained in:
@@ -50,6 +50,7 @@ class WXDLLIMPEXP_FWD_CORE wxDialog;
|
|||||||
class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
|
class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane, bool wantsUserKey ) ;
|
||||||
wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false, bool isUserPane = false ) ;
|
wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false, bool isUserPane = false ) ;
|
||||||
wxWidgetCocoaImpl() ;
|
wxWidgetCocoaImpl() ;
|
||||||
~wxWidgetCocoaImpl();
|
~wxWidgetCocoaImpl();
|
||||||
|
@@ -216,6 +216,7 @@ protected :
|
|||||||
class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject
|
class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane, bool wantsUserKey );
|
||||||
wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false );
|
wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false );
|
||||||
wxWidgetImpl();
|
wxWidgetImpl();
|
||||||
virtual ~wxWidgetImpl();
|
virtual ~wxWidgetImpl();
|
||||||
@@ -224,8 +225,12 @@ public :
|
|||||||
|
|
||||||
bool IsRootControl() const { return m_isRootControl; }
|
bool IsRootControl() const { return m_isRootControl; }
|
||||||
|
|
||||||
|
// is a completely control that has all events handled in wx code, no built-ins
|
||||||
bool IsUserPane() const { return m_isUserPane; }
|
bool IsUserPane() const { return m_isUserPane; }
|
||||||
|
|
||||||
|
// we are doing keyboard handling in wx code, other events might be handled natively
|
||||||
|
virtual bool HasUserKeyHandling() const { return m_wantsUserKey; }
|
||||||
|
|
||||||
wxWindowMac* GetWXPeer() const { return m_wxPeer; }
|
wxWindowMac* GetWXPeer() const { return m_wxPeer; }
|
||||||
|
|
||||||
bool IsOk() const { return GetWXWidget() != NULL; }
|
bool IsOk() const { return GetWXWidget() != NULL; }
|
||||||
@@ -572,6 +577,7 @@ public :
|
|||||||
protected :
|
protected :
|
||||||
bool m_isRootControl;
|
bool m_isRootControl;
|
||||||
bool m_isUserPane;
|
bool m_isUserPane;
|
||||||
|
bool m_wantsUserKey;
|
||||||
wxWindowMac* m_wxPeer;
|
wxWindowMac* m_wxPeer;
|
||||||
bool m_needsFocusRect;
|
bool m_needsFocusRect;
|
||||||
bool m_needsFrame;
|
bool m_needsFrame;
|
||||||
|
@@ -140,6 +140,15 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *GLAttrs,
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for special keys
|
||||||
|
|
||||||
|
- (void)doCommandBySelector:(SEL)aSelector
|
||||||
|
{
|
||||||
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if (impl)
|
||||||
|
impl->doCommandBySelector(aSelector, self, _cmd);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
bool wxGLCanvas::DoCreate(wxWindow *parent,
|
bool wxGLCanvas::DoCreate(wxWindow *parent,
|
||||||
@@ -149,7 +158,6 @@ bool wxGLCanvas::DoCreate(wxWindow *parent,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
|
|
||||||
DontCreatePeer();
|
DontCreatePeer();
|
||||||
|
|
||||||
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
|
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
|
||||||
@@ -159,13 +167,12 @@ bool wxGLCanvas::DoCreate(wxWindow *parent,
|
|||||||
NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
|
NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
|
||||||
wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
|
wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
|
||||||
|
|
||||||
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( this, v );
|
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( this, v, false, false, true /* wants key events */ );
|
||||||
SetPeer(c);
|
SetPeer(c);
|
||||||
MacPostControlCreate(pos, size) ;
|
MacPostControlCreate(pos, size) ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxGLCanvas::~wxGLCanvas()
|
wxGLCanvas::~wxGLCanvas()
|
||||||
{
|
{
|
||||||
if ( m_glFormat )
|
if ( m_glFormat )
|
||||||
|
@@ -897,7 +897,7 @@ static void SetDrawingEnabledIfFrozenRecursive(wxWidgetCocoaImpl *impl, bool ena
|
|||||||
- (BOOL) canBecomeKeyView
|
- (BOOL) canBecomeKeyView
|
||||||
{
|
{
|
||||||
wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( viewimpl && viewimpl->IsUserPane() && viewimpl->GetWXPeer() )
|
if ( viewimpl && viewimpl->HasUserKeyHandling() && viewimpl->GetWXPeer() )
|
||||||
return viewimpl->GetWXPeer()->AcceptsFocus();
|
return viewimpl->GetWXPeer()->AcceptsFocus();
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -2101,7 +2101,7 @@ void wxCocoaGesturesImpl::TouchesEnded(NSEvent* event)
|
|||||||
void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
void wxWidgetCocoaImpl::insertText(NSString* text, WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if ( IsUserPane() && !m_hasEditor && [text length] > 0)
|
if ( HasUserKeyHandling() && !m_hasEditor && [text length] > 0)
|
||||||
{
|
{
|
||||||
if ( m_lastKeyDownEvent!=NULL && [text isEqualToString:[m_lastKeyDownEvent characters]])
|
if ( m_lastKeyDownEvent!=NULL && [text isEqualToString:[m_lastKeyDownEvent characters]])
|
||||||
{
|
{
|
||||||
@@ -2190,7 +2190,7 @@ bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, voi
|
|||||||
|
|
||||||
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
|
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
if ( IsUserPane() )
|
if ( HasUserKeyHandling() )
|
||||||
return m_wxPeer->AcceptsFocus();
|
return m_wxPeer->AcceptsFocus();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2512,8 +2512,8 @@ void wxOSXCocoaClassAddWXMethods(Class c, wxOSXSkipOverrides skipFlags)
|
|||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxWidgetCocoaImpl , wxWidgetImpl);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxWidgetCocoaImpl , wxWidgetImpl);
|
||||||
|
|
||||||
wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane ) :
|
wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane, bool wantsKey ) :
|
||||||
wxWidgetImpl( peer, isRootControl, isUserPane )
|
wxWidgetImpl( peer, isRootControl, isUserPane, wantsKey )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_osxView = w;
|
m_osxView = w;
|
||||||
@@ -2528,6 +2528,23 @@ wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRoo
|
|||||||
[m_osxView release];
|
[m_osxView release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane ) :
|
||||||
|
wxWidgetImpl( peer, isRootControl, isUserPane )
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
m_osxView = w;
|
||||||
|
|
||||||
|
// check if the user wants to create the control initially hidden
|
||||||
|
if ( !peer->IsShown() )
|
||||||
|
SetVisibility(false);
|
||||||
|
|
||||||
|
// gc aware handling
|
||||||
|
if ( m_osxView )
|
||||||
|
CFRetain(m_osxView);
|
||||||
|
[m_osxView release];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxWidgetCocoaImpl::wxWidgetCocoaImpl()
|
wxWidgetCocoaImpl::wxWidgetCocoaImpl()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
@@ -3658,7 +3675,7 @@ bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsUserPane() && [event type] == NSKeyDown)
|
if ( HasUserKeyHandling() && [event type] == NSKeyDown)
|
||||||
{
|
{
|
||||||
// Don't fire wxEVT_KEY_DOWN here in order to allow IME to intercept
|
// Don't fire wxEVT_KEY_DOWN here in order to allow IME to intercept
|
||||||
// some key events. If the event is not handled by IME, either
|
// some key events. If the event is not handled by IME, either
|
||||||
|
@@ -2223,7 +2223,7 @@ void wxWindowMac::MacRepositionScrollBars()
|
|||||||
|
|
||||||
bool wxWindowMac::AcceptsFocus() const
|
bool wxWindowMac::AcceptsFocus() const
|
||||||
{
|
{
|
||||||
if ( GetPeer() == NULL || GetPeer()->IsUserPane() )
|
if ( GetPeer() == NULL || GetPeer()->HasUserKeyHandling() )
|
||||||
return wxWindowBase::AcceptsFocus();
|
return wxWindowBase::AcceptsFocus();
|
||||||
else
|
else
|
||||||
return GetPeer()->CanFocus();
|
return GetPeer()->CanFocus();
|
||||||
@@ -2742,10 +2742,20 @@ void wxWidgetImpl::RemoveAssociation(WXWidget control)
|
|||||||
wxIMPLEMENT_ABSTRACT_CLASS(wxWidgetImpl, wxObject);
|
wxIMPLEMENT_ABSTRACT_CLASS(wxWidgetImpl, wxObject);
|
||||||
|
|
||||||
wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane )
|
wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane )
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
m_isRootControl = isRootControl;
|
||||||
|
m_wantsUserKey = m_isUserPane = isUserPane;
|
||||||
|
m_wxPeer = peer;
|
||||||
|
m_shouldSendEvents = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane, bool wantsUserKey )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_isRootControl = isRootControl;
|
m_isRootControl = isRootControl;
|
||||||
m_isUserPane = isUserPane;
|
m_isUserPane = isUserPane;
|
||||||
|
m_wantsUserKey = wantsUserKey;
|
||||||
m_wxPeer = peer;
|
m_wxPeer = peer;
|
||||||
m_shouldSendEvents = true;
|
m_shouldSendEvents = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user