mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-14 10:43:50 +00:00
Properly catch single-click, double-click, dragging on a divider
Previously, a double-click was also catched as a single-click on mouse up, dragging was handled is mouse down before tracking actually begins. Manual test: added collapse capabilities to all split views.
This commit is contained in:
1 parent
258cd9209f
commit
7a02cd794b
2 files changed
+36
-12
No files matched your search
+19
-5
@@ -117,6 +117,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
CPArray _DOMDividerElements;
|
||||
CPString _dividerImagePath;
|
||||
int _drawingDivider;
|
||||
BOOL _isTracking;
|
||||
|
||||
CPString _autosaveName;
|
||||
BOOL _shouldAutosave;
|
||||
@@ -158,6 +159,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
_buttonBars = [];
|
||||
|
||||
_shouldAutosave = YES;
|
||||
_isTracking = NO;
|
||||
|
||||
[self _setVertical:YES];
|
||||
}
|
||||
@@ -473,12 +475,13 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
|
||||
if (type == CPLeftMouseUp)
|
||||
{
|
||||
// We disabled autosaving during tracking.
|
||||
_shouldAutosave = YES;
|
||||
|
||||
if (_currentDivider != CPNotFound)
|
||||
if ([anEvent clickCount] == 2 || (_isTracking && _currentDivider != CPNotFound))
|
||||
{
|
||||
// We disabled autosaving during tracking.
|
||||
_shouldAutosave = YES;
|
||||
_currentDivider = CPNotFound;
|
||||
_isTracking = NO;
|
||||
|
||||
[self _autosave];
|
||||
[self _updateResizeCursor:anEvent];
|
||||
}
|
||||
@@ -504,6 +507,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
[self _delegateRespondsToSplitViewCanCollapseSubview] &&
|
||||
[self _delegateRespondsToSplitViewshouldCollapseSubviewForDoubleClickOnDividerAtIndex])
|
||||
{
|
||||
_currentDivider = i;
|
||||
var minPosition = [self minPossiblePositionOfDividerAtIndex:i],
|
||||
maxPosition = [self maxPossiblePositionOfDividerAtIndex:i],
|
||||
preCollapsePosition = [_preCollapsePositions objectForKey:"" + i] || 0;
|
||||
@@ -543,6 +547,15 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
|
||||
else if (type == CPLeftMouseDragged && _currentDivider != CPNotFound)
|
||||
{
|
||||
if (!_isTracking)
|
||||
{
|
||||
// Don't autosave during a resize. We'll wait until it's done.
|
||||
_shouldAutosave = NO;
|
||||
[self _postNotificationWillResize];
|
||||
|
||||
_isTracking = YES;
|
||||
}
|
||||
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
|
||||
[self setPosition:(point[_originComponent] + _initialOffset) ofDividerAtIndex:_currentDivider];
|
||||
@@ -1195,7 +1208,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
[self removeAllTrackingAreas];
|
||||
|
||||
var options = CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow;
|
||||
|
||||
|
||||
for (var i = 0; i < _subviews.length - 1; i++)
|
||||
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:[self effectiveRectOfDividerAtIndex:i]
|
||||
options:options
|
||||
@@ -1440,6 +1453,7 @@ var CPSplitViewDelegateKey = "CPSplitViewDelegateKey",
|
||||
|
||||
_currentDivider = CPNotFound;
|
||||
_shouldAutosave = YES;
|
||||
_isTracking = NO;
|
||||
|
||||
_DOMDividerElements = [];
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
[splitViewA setDelegate:self];
|
||||
|
||||
[splitViewB setDelegate:self];
|
||||
[splitViewC setDelegate:self];
|
||||
// This is called when the cib is done loading.
|
||||
// You can implement this method on any object instantiated from a Cib.
|
||||
// It's a useful hook for setting up current UI values, and other things.
|
||||
@@ -36,12 +37,6 @@
|
||||
[theWindow setFullPlatformWindow:YES];
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldAdjustSizeOfSubview:(CPView)subview
|
||||
{
|
||||
var subviews = [splitView subviews];
|
||||
return (subview !== [subviews objectAtIndex:1]);
|
||||
}
|
||||
|
||||
- (@action)deleteAutosave:(id)sender
|
||||
{
|
||||
[splitViewA deleteAutosave];
|
||||
@@ -84,5 +79,20 @@
|
||||
console.error(@"splitViewWillResizeSubviews")
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldAdjustSizeOfSubview:(CPView)subview
|
||||
{
|
||||
var subviews = [splitView subviews];
|
||||
return (subview !== [subviews objectAtIndex:1]);
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView canCollapseSubview:(CPView)subview
|
||||
{
|
||||
return subview == [[splitView subviews] objectAtIndex:0];
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldCollapseSubview:(CPView)subview forDoubleClickOnDividerAtIndex:(CPInteger)dividerIndex
|
||||
{
|
||||
return dividerIndex == 0;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user