Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cappuccino/cappuccino
Browse files Browse the repository at this point in the history
  • Loading branch information
aljungberg committed Mar 27, 2012
2 parents 38f8b1a + 9e8f659 commit 8df2e60
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
47 changes: 34 additions & 13 deletions AppKit/CPMenu/_CPMenuManager.j
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var STICKY_TIME_INTERVAL = 500,
@implementation _CPMenuManager: CPObject
{
CPTimeInterval _startTime;
BOOL _hasMouseGoneUpAfterStartedTracking;
BOOL _mouseWasDragged;
int _scrollingState;
CGPoint _lastGlobalLocation;

Expand Down Expand Up @@ -66,7 +66,7 @@ var STICKY_TIME_INTERVAL = 500,

CPApp._activeMenu = menu;

_startTime = [anEvent timestamp];//new Date();
_startTime = [anEvent timestamp];
_scrollingState = _CPMenuManagerScrollingStateNone;

_constraintRect = aRect;
Expand All @@ -91,7 +91,7 @@ var STICKY_TIME_INTERVAL = 500,
return [self trackMenuBarButtonEvent:anEvent];
}

_hasMouseGoneUpAfterStartedTracking = NO;
_mouseWasDragged = NO;

[self trackEvent:anEvent];
}
Expand Down Expand Up @@ -189,7 +189,7 @@ var STICKY_TIME_INTERVAL = 500,

var menuContainerWindow = activeMenuContainer;

if (![menuContainerWindow isKindOfClass:[CPWindow class]])
if (![menuContainerWindow isKindOfClass:CPWindow])
menuContainerWindow = [menuContainerWindow window];

[menuContainerWindow
Expand All @@ -215,6 +215,9 @@ var STICKY_TIME_INTERVAL = 500,

if (type === CPMouseMoved || type === CPLeftMouseDragged || type === CPLeftMouseDown || type === CPPeriodic)
{
if (type === CPLeftMouseDragged)
_mouseWasDragged = YES;

var oldScrollingState = _scrollingState;

_scrollingState = [activeMenuContainer scrollingStateForPoint:globalLocation];
Expand All @@ -229,17 +232,35 @@ var STICKY_TIME_INTERVAL = 500,
}
else if (type === CPLeftMouseUp || type === CPRightMouseUp)
{
if (_hasMouseGoneUpAfterStartedTracking)
{
// Don't close the menu if the current item has a submenu
// and did not override it's default action
if ([activeItem action] === @selector(submenuAction:))
return;
/*
There are a few possibilites:
1. The user clicks and releases without dragging within the sticky time.
This is considered a regular mouse click and not a drag. In this case
we allow the user to track the menu by moving the mouse. The next
mouse up will end tracking.
2. The user clicks and releases without dragging after the sticky time.
This is considered a drag and release and tracking ends.
[trackingMenu cancelTracking];
3. The user clicks, drags and then releases. Tracking ends.
*/
if (_mouseWasDragged || [anEvent timestamp] - _startTime > STICKY_TIME_INTERVAL)
{
/*
Close the menu if:
1. The mouse was dragged.
2. The mouse is released in the menubar.
3. The current item has a submenu with a custom action.
*/
if (_mouseWasDragged ||
[activeMenuContainer isKindOfClass:_CPMenuBarWindow] ||
[activeItem action] !== @selector(submenuAction:))
{
[trackingMenu cancelTracking];
}
}
else
_hasMouseGoneUpAfterStartedTracking = YES;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tools/Documentation/Cappuccino.doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ MAN_LINKS = NO
# generate an XML file that captures the structure of
# the code including all documentation.

GENERATE_XML = YES
GENERATE_XML = NO

# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
Expand Down

0 comments on commit 8df2e60

Please sign in to comment.