]> git.saurik.com Git - wxWidgets.git/commitdiff
removing NSWindow based mouse tracking in favour of 10.5+ trackingArea implementation
authorStefan Csomor <csomor@advancedconcepts.ch>
Sat, 10 Mar 2012 12:37:58 +0000 (12:37 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sat, 10 Mar 2012 12:37:58 +0000 (12:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/nonownedwnd.mm
src/osx/cocoa/window.mm

index 81ecf321aa53dfa9a173cc6cbb2b7c8bb439a30b..a83bd48ba0e50b95d1c731cb3ef18c73da1553ae 100644 (file)
@@ -131,22 +131,6 @@ bool shouldHandleSelector(SEL selector)
             ((wxWidgetCocoaImpl*)cw->GetPeer())->DoHandleMouseEvent( event);
             handled = true;
         }
-        else if ( [event type] == NSMouseMoved )
-        {
-            NSPoint nsPoint = [event locationInWindow];
-            if ( [event window] != nil )
-                nsPoint = [[event window] convertBaseToScreen:nsPoint];
-
-            wxPoint pt = wxFromNSPoint(NULL, nsPoint);
-            wxWindow* mw = ::wxFindWindowAtPoint(pt);
-            if ( mw )
-            {
-                if (wxTheApp)
-                    wxTheApp->MacSetCurrentEvent(event, NULL);
-                ((wxWidgetCocoaImpl*)mw->GetPeer())->DoHandleMouseEvent( event);
-                handled = true;
-            }
-        }
         if ( handled )
         {
             if (wxTheApp)
@@ -654,8 +638,6 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
 
     [m_macWindow setDelegate:controller];
 
-    [m_macWindow setAcceptsMouseMovedEvents: YES];
-    
     if ( ( style & wxFRAME_SHAPED) )
     {
         [m_macWindow setOpaque:NO];
index fd719046798481b46cab114447bf961b219341ad..e809a3dad4e11759b706656a345c69d609fa5555 100644 (file)
@@ -92,11 +92,8 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
     id              _lastToolTipOwner;
     void*           _lastUserData;
     
-    NSTrackingArea* _trackingArea;
 }
 
-- (void) updateTrackingArea;
-- (NSTrackingArea*) trackingArea;
 @end // wxNSView
 
 @interface NSView(PossibleMethods)
@@ -684,27 +681,6 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
     }
 }
 
-- (void) updateTrackingArea
-{
-    if (_trackingArea)
-    {
-        [self removeTrackingArea: _trackingArea];
-        [_trackingArea release];
-    }
-    
-    NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveAlways;
-        
-    NSTrackingArea* area = [[NSTrackingArea alloc] initWithRect: [self bounds] options: options owner: self userInfo: nil];
-    [self addTrackingArea: area];
-
-    _trackingArea = area;
-}
-
-- (NSTrackingArea*) trackingArea
-{
-    return _trackingArea;
-}
-
 /* idea taken from webkit sources: overwrite the methods that (private) NSToolTipManager will use to attach its tracking rectangle 
  * then when changing the tooltip send fake view-exit and view-enter methods which will lead to a tooltip refresh
  */
@@ -2010,11 +1986,6 @@ void wxWidgetCocoaImpl::Move(int x, int y, int width, int height)
     NSRect r = wxToNSRect( [m_osxView superview], wxRect(x,y,width, height) );
     [m_osxView setFrame:r];
     [[m_osxView superview] setNeedsDisplayInRect:r];
-
-    wxNSView* wxview = (wxNSView*)m_osxView;
-
-    if ([wxview respondsToSelector:@selector(updateTrackingArea)] )
-        [wxview updateTrackingArea]; 
 }
 
 void wxWidgetCocoaImpl::GetPosition( int &x, int &y ) const
@@ -2402,7 +2373,11 @@ void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
         }
 
     }
-}
+    NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveAlways|NSTrackingInVisibleRect;
+        NSTrackingArea* area = [[NSTrackingArea alloc] initWithRect: NSZeroRect options: options owner: m_osxView userInfo: nil];
+    [m_osxView addTrackingArea: area];
+    [area release];
+ }
 
 bool wxWidgetCocoaImpl::DoHandleCharEvent(NSEvent *event, NSString *text)
 {