@interface wxNSView : NSView
{
NSTrackingRectTag rectTag;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+ NSTrackingArea* _trackingArea;
+#endif
}
// the tracking tag is needed to track mouse enter / exit events
- (void) setTrackingTag: (NSTrackingRectTag)tag;
- (NSTrackingRectTag) trackingTag;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+// under 10.5 we can also track mouse moved events on non-focused windows if
+// we use the new NSTrackingArea APIs.
+- (void) updateTrackingArea;
+- (NSTrackingArea*) trackingArea;
+#endif
@end // wxNSView
@interface NSView(PossibleMethods)
return rectTag;
}
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+- (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;
+}
+#endif
@end // wxNSView
//
impl->mouseEvent(event, self, _cmd);
}
+BOOL wxOSX_acceptsFirstMouse(NSView* self, SEL _cmd, NSEvent *event)
+{
+ // This is needed to support click through, otherwise the first click on a window
+ // will not do anything unless it is the active window already.
+ return YES;
+}
+
void wxOSX_keyEvent(NSView* self, SEL _cmd, NSEvent *event)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseDragged:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(rightMouseDragged:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(otherMouseDragged:), (IMP) wxOSX_mouseEvent, "v@:@" )
+
+ wxOSX_CLASS_ADD_METHOD(c, @selector(acceptsFirstMouse:), (IMP) wxOSX_acceptsFirstMouse, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(scrollWheel:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
[m_osxView setFrame:r];
[[m_osxView superview] setNeedsDisplayInRect:r];
+ wxNSView* wxview = (wxNSView*)m_osxView;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+ if ([wxview respondsToSelector:@selector(updateTrackingArea)] )
+ [wxview updateTrackingArea];
+#else
if ([m_osxView respondsToSelector:@selector(trackingTag)] )
{
- if ( [(wxNSView*)m_osxView trackingTag] )
- [m_osxView removeTrackingRect: [(wxNSView*)m_osxView trackingTag]];
+ if ( [wxview trackingTag] )
+ [wxview removeTrackingRect: [wxview trackingTag]];
- [(wxNSView*)m_osxView setTrackingTag: [m_osxView addTrackingRect: [m_osxView bounds] owner: m_osxView userData: nil assumeInside: NO]];
+ [wxview setTrackingTag: [wxview addTrackingRect: [m_osxView bounds] owner: wxview userData: nil assumeInside: NO]];
}
+#endif
}
void wxWidgetCocoaImpl::GetPosition( int &x, int &y ) const