diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 5af7d9b63..37ba2421a 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -286,9 +286,14 @@ var CPControlBlackColor = [CPColor blackColor]; [self stopTracking:_previousTrackingLocation at:currentLocation mouseIsUp:YES]; _trackingMouseDownFlags = 0; + + if (isWithinFrame) + [self setThemeState:CPThemeStateHovered]; } else { + [self unsetThemeState:CPThemeStateHovered]; + if (type === CPLeftMouseDown) { _trackingMouseDownFlags = [anEvent modifierFlags]; @@ -384,6 +389,25 @@ var CPControlBlackColor = [CPColor blackColor]; [self trackMouse:anEvent]; } +- (void)mouseEntered:(CPEvent)anEvent +{ + if (![self isEnabled]) + return; + + [self setThemeState:CPThemeStateHovered]; +} + +- (void)mouseExited:(CPEvent)anEvent +{ + var currentLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil], + isWithinFrame = [self tracksMouseOutsideOfFrame] || CGRectContainsPoint([self bounds], currentLocation); + + // Make sure we're not still in the frame because Cappuccino will sent mouseExited events + // for all of the (ephemeral) subviews of a view as well. + if (!isWithinFrame) + [self unsetThemeState:CPThemeStateHovered]; +} + /*! Returns the receiver's object value */ diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index 7e854b147..ff37bee69 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -405,6 +405,7 @@ function CPThemeStateName(aState) CPThemeStateNames[0] = "normal"; CPThemeStateNormal = CPThemeStates["normal"] = 0; CPThemeStateDisabled = CPThemeState("disabled"); +CPThemeStateHovered = CPThemeState("hovered"); CPThemeStateHighlighted = CPThemeState("highlighted"); CPThemeStateSelected = CPThemeState("selected"); CPThemeStateTableDataView = CPThemeState("tableDataView"); diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 032b19382..a0b6f51c9 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -388,6 +388,7 @@ CPTexturedBackgroundWindowMask _registeredDraggedTypes = [CPSet set]; _registeredDraggedTypesArray = []; _isSheet = NO; + _acceptsMouseMovedEvents = YES; // Set up our window number. _windowNumber = [CPApp._windows count];