cleaning up key handling, closes #10406
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -133,6 +133,10 @@ public :
|
|||||||
virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
|
virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
|
||||||
virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
|
virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
|
||||||
|
|
||||||
|
virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
|
||||||
|
virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
|
||||||
|
|
||||||
|
|
||||||
void SetFlipped(bool flipped);
|
void SetFlipped(bool flipped);
|
||||||
virtual bool IsFlipped() const { return m_isFlipped; }
|
virtual bool IsFlipped() const { return m_isFlipped; }
|
||||||
|
|
||||||
|
@@ -512,7 +512,7 @@ void wxListWidgetCocoaImpl::controlDoubleAction(WXWidget WXUNUSED(slf),void* WXU
|
|||||||
list->HandleLineEvent( sel, true );
|
list->HandleLineEvent( sel, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
bool wxListWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
||||||
{
|
{
|
||||||
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
||||||
SetupKeyEvent( wxevent, event );
|
SetupKeyEvent( wxevent, event );
|
||||||
|
@@ -271,7 +271,7 @@ long wxOSXTranslateCocoaKey( NSEvent* event )
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupKeyEvent( wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charString = NULL )
|
void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charString)
|
||||||
{
|
{
|
||||||
UInt32 modifiers = [nsEvent modifierFlags] ;
|
UInt32 modifiers = [nsEvent modifierFlags] ;
|
||||||
int eventType = [nsEvent type];
|
int eventType = [nsEvent type];
|
||||||
@@ -350,12 +350,19 @@ void SetupKeyEvent( wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charStrin
|
|||||||
wxevent.m_uniChar = aunichar;
|
wxevent.m_uniChar = aunichar;
|
||||||
#endif
|
#endif
|
||||||
wxevent.m_keyCode = keyval;
|
wxevent.m_keyCode = keyval;
|
||||||
|
|
||||||
|
wxWindowMac* peer = GetWXPeer();
|
||||||
|
if ( peer )
|
||||||
|
{
|
||||||
|
wxevent.SetEventObject(peer);
|
||||||
|
wxevent.SetId(peer->GetId()) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 g_lastButton = 0 ;
|
UInt32 g_lastButton = 0 ;
|
||||||
bool g_lastButtonWasFakeRight = false ;
|
bool g_lastButtonWasFakeRight = false ;
|
||||||
|
|
||||||
void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
||||||
{
|
{
|
||||||
int eventType = [nsEvent type];
|
int eventType = [nsEvent type];
|
||||||
UInt32 modifiers = [nsEvent modifierFlags] ;
|
UInt32 modifiers = [nsEvent modifierFlags] ;
|
||||||
@@ -521,7 +528,12 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxevent.m_clickCount = clickCount;
|
wxevent.m_clickCount = clickCount;
|
||||||
|
wxWindowMac* peer = GetWXPeer();
|
||||||
|
if ( peer )
|
||||||
|
{
|
||||||
|
wxevent.SetEventObject(peer);
|
||||||
|
wxevent.SetId(peer->GetId()) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation wxNSView
|
@implementation wxNSView
|
||||||
@@ -1554,7 +1566,6 @@ bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text)
|
|||||||
{
|
{
|
||||||
wxKeyEvent wxevent(wxEVT_CHAR);
|
wxKeyEvent wxevent(wxEVT_CHAR);
|
||||||
SetupKeyEvent( wxevent, event, text );
|
SetupKeyEvent( wxevent, event, text );
|
||||||
wxevent.SetEventObject(GetWXPeer());
|
|
||||||
|
|
||||||
return GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
return GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
||||||
}
|
}
|
||||||
@@ -1563,7 +1574,6 @@ bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
|||||||
{
|
{
|
||||||
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
||||||
SetupKeyEvent( wxevent, event );
|
SetupKeyEvent( wxevent, event );
|
||||||
wxevent.SetEventObject(GetWXPeer());
|
|
||||||
bool result = GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
bool result = GetWXPeer()->OSXHandleKeyEvent(wxevent);
|
||||||
|
|
||||||
// this will fire higher level events, like insertText, to help
|
// this will fire higher level events, like insertText, to help
|
||||||
@@ -1589,8 +1599,7 @@ bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
|
|||||||
clickLocation = [m_osxView convertPoint:[event locationInWindow] fromView:nil];
|
clickLocation = [m_osxView convertPoint:[event locationInWindow] fromView:nil];
|
||||||
wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
|
wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
|
||||||
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
||||||
SetupMouseEvent( wxevent , event ) ;
|
SetupMouseEvent(wxevent , event) ;
|
||||||
wxevent.SetEventObject(GetWXPeer());
|
|
||||||
wxevent.m_x = pt.x;
|
wxevent.m_x = pt.x;
|
||||||
wxevent.m_y = pt.y;
|
wxevent.m_y = pt.y;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user