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:
Stefan Csomor 2009-09-26 10:39:26 +00:00
parent a1d5aa9361
commit ddbc8ac9ca
3 changed files with 21 additions and 8 deletions

View File

@ -132,6 +132,10 @@ public :
virtual bool DoHandleKeyEvent(NSEvent *event);
virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
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);
virtual bool IsFlipped() const { return m_isFlipped; }

View File

@ -512,7 +512,7 @@ void wxListWidgetCocoaImpl::controlDoubleAction(WXWidget WXUNUSED(slf),void* WXU
list->HandleLineEvent( sel, true );
}
bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
bool wxListWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
{
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
SetupKeyEvent( wxevent, event );

View File

@ -271,7 +271,7 @@ long wxOSXTranslateCocoaKey( NSEvent* event )
return retval;
}
void SetupKeyEvent( wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charString = NULL )
void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charString)
{
UInt32 modifiers = [nsEvent modifierFlags] ;
int eventType = [nsEvent type];
@ -350,12 +350,19 @@ void SetupKeyEvent( wxKeyEvent &wxevent , NSEvent * nsEvent, NSString* charStrin
wxevent.m_uniChar = aunichar;
#endif
wxevent.m_keyCode = keyval;
wxWindowMac* peer = GetWXPeer();
if ( peer )
{
wxevent.SetEventObject(peer);
wxevent.SetId(peer->GetId()) ;
}
}
UInt32 g_lastButton = 0 ;
bool g_lastButtonWasFakeRight = false ;
void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
{
int eventType = [nsEvent type];
UInt32 modifiers = [nsEvent modifierFlags] ;
@ -521,7 +528,12 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
}
wxevent.m_clickCount = clickCount;
wxWindowMac* peer = GetWXPeer();
if ( peer )
{
wxevent.SetEventObject(peer);
wxevent.SetId(peer->GetId()) ;
}
}
@implementation wxNSView
@ -1554,7 +1566,6 @@ bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text)
{
wxKeyEvent wxevent(wxEVT_CHAR);
SetupKeyEvent( wxevent, event, text );
wxevent.SetEventObject(GetWXPeer());
return GetWXPeer()->OSXHandleKeyEvent(wxevent);
}
@ -1563,7 +1574,6 @@ bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
{
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
SetupKeyEvent( wxevent, event );
wxevent.SetEventObject(GetWXPeer());
bool result = GetWXPeer()->OSXHandleKeyEvent(wxevent);
// 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];
wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
SetupMouseEvent( wxevent , event ) ;
wxevent.SetEventObject(GetWXPeer());
SetupMouseEvent(wxevent , event) ;
wxevent.m_x = pt.x;
wxevent.m_y = pt.y;