mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
Crazy cool selection behavior.
This commit is contained in:
1 parent
85f51d7a66
commit
d27544f2bf
1 file changed
+44
-1
+44
-1
@@ -235,6 +235,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
BOOL _disableAutomaticResizing @accessors(property=disableAutomaticResizing);
|
||||
BOOL _lastColumnShouldSnap;
|
||||
BOOL _implementsCustomDrawRow;
|
||||
BOOL _wasBroken;
|
||||
|
||||
CPTableColumn _draggedColumn;
|
||||
CPArray _differedColumnDataToRemove;
|
||||
@@ -4433,6 +4434,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
[super keyDown:anEvent];
|
||||
}
|
||||
|
||||
- (BOOL)selectionIsBroken
|
||||
{
|
||||
return [self selectedRowIndexes]._ranges.length !== 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Selection behaviour depends on two things:
|
||||
@@ -4449,8 +4455,23 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
var extend = (([theEvent modifierFlags] & CPShiftKeyMask) && _allowsMultipleSelection),
|
||||
i = [self selectedRow];
|
||||
|
||||
while ([selectedIndexes containsIndex:i])
|
||||
if([self selectionIsBroken])
|
||||
{
|
||||
while ([selectedIndexes containsIndex:i])
|
||||
{
|
||||
shouldGoUpward ? i-- : i++;
|
||||
}
|
||||
_wasBroken = true;
|
||||
}
|
||||
else if (_wasBroken && ((shouldGoUpward && i !== [selectedIndexes leastIndex]) || (!shouldGoUpward && i !== [selectedIndexes mostIndex])))
|
||||
{
|
||||
shouldGoUpward ? i = [selectedIndexes leastIndex] - 1 : i = [selectedIndexes mostIndex];
|
||||
_wasBroken = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldGoUpward ? i-- : i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4517,6 +4538,28 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPIndexSet (LeastAndMost)
|
||||
|
||||
- (int)leastIndex
|
||||
{
|
||||
var least = _ranges[0].location;
|
||||
for(var i = 1; i < _ranges.length; i++)
|
||||
if (_ranges[i].location < least)
|
||||
least = _ranges[i].location;
|
||||
return least;
|
||||
}
|
||||
|
||||
- (int)mostIndex
|
||||
{
|
||||
var most = _ranges[0].location + _ranges[0].length;
|
||||
for(var i = 1; i < _ranges.length; i++)
|
||||
if (_ranges[i].location + _ranges[i].length > most)
|
||||
most = _ranges[i].location + _ranges[i].length;
|
||||
return most;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTableView (Bindings)
|
||||
|
||||
/*!
|
||||
|
||||
Reference in new issue
Block a user