]> git.saurik.com Git - wxWidgets.git/commitdiff
cleaning up key handling, closes #10406
authorStefan Csomor <csomor@advancedconcepts.ch>
Sat, 26 Sep 2009 10:39:26 +0000 (10:39 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sat, 26 Sep 2009 10:39:26 +0000 (10:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/private.h
src/osx/cocoa/listbox.mm
src/osx/cocoa/window.mm

index a1df4213036db53c38297982052b0529a4d88d2b..291a549dc43abbb3c32cf7592308a5c71822b7e9 100644 (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; }
index 79389e8306ccb34e5265fbfbfc9106465553b7eb..2ba3fde0e2e8d738088ef62dd41f17849c049d11 100644 (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 );
index 7bf085d65b4190e22a534f651f56036045f77262..064d7ab2340e1a1efb6616f59714b6dc2ff3fc46 100644 (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;