mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
Rewrote _selectColumn:modifiers: to be simpler, support selection by range as
Cocoa does, and remove the toggle selection behavior when a column is clicked twice (in conflict with the ability to change the sort direction). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29296 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
83dac5cfec
commit
ec403f1296
2 changed files with 51 additions and 65 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-01-16 Quentin Mathe <quentin.mathe@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSTableView.m (-_selectColumn:modifiers:): Rewrote to be
|
||||||
|
simpler, support selection by range as Cocoa does and to remove the
|
||||||
|
toggle selection behavior when a column is clicked twice. This toggle
|
||||||
|
behavior was in conflict with the ability to change the sort direction
|
||||||
|
by clicking in an already selected column header.
|
||||||
|
|
||||||
2010-01-16 14:55-EST Gregory John Casamento <greg.casamento@gmail.com>
|
2010-01-16 14:55-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
* Source/NSWindow.m: Don't use the flags for key/main window tracking.
|
* Source/NSWindow.m: Don't use the flags for key/main window tracking.
|
||||||
|
|
|
@ -2359,84 +2359,62 @@ static void computeNewSelection
|
||||||
/*
|
/*
|
||||||
* And this when it gets a simple click which turns out to be for
|
* And this when it gets a simple click which turns out to be for
|
||||||
* selecting/deselecting a column.
|
* selecting/deselecting a column.
|
||||||
|
* We don't support subtracting a column from the selection (Cocoa doesn't
|
||||||
|
* either).
|
||||||
|
* However we support adding a distinct column with the control key (unlike
|
||||||
|
* Cocoa where the user can only make column range selection).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
- (void) _selectColumn: (int)columnIndex
|
- (void) _selectColumn: (int)columnIndex
|
||||||
modifiers: (unsigned int)modifiers
|
modifiers: (unsigned int)modifiers
|
||||||
{
|
{
|
||||||
if (_allowsColumnSelection == NO)
|
NSIndexSet *oldIndexes = [self selectedColumnIndexes];
|
||||||
|
BOOL addRange = ((modifiers & NSShiftKeyMask)
|
||||||
|
&& _allowsMultipleSelection && [oldIndexes count] > 0);
|
||||||
|
BOOL addSingle = ((modifiers & NSControlKeyMask)
|
||||||
|
&& _allowsMultipleSelection);
|
||||||
|
BOOL shouldSelect = ([self _shouldSelectionChange]
|
||||||
|
&& [self _shouldSelectTableColumn: [_tableColumns objectAtIndex: columnIndex]]);
|
||||||
|
NSIndexSet *newIndexes = [NSIndexSet indexSetWithIndex: columnIndex];
|
||||||
|
|
||||||
|
if (_allowsColumnSelection == NO || shouldSelect == NO)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([self isColumnSelected: columnIndex] == YES)
|
if (_selectingColumns == NO)
|
||||||
{
|
{
|
||||||
if (([_selectedColumns count] == 1) && (_allowsEmptySelection == NO))
|
[self _setSelectingColumns: YES];
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([self _shouldSelectionChange] == NO)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_selectingColumns == NO)
|
|
||||||
{
|
|
||||||
[self _setSelectingColumns: YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self deselectColumn: columnIndex];
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else // column is not selected
|
|
||||||
|
/* Single select has priority over range select when both modifiers are pressed */
|
||||||
|
if (addSingle)
|
||||||
|
{
|
||||||
|
[self selectColumnIndexes: newIndexes byExtendingSelection: YES];
|
||||||
|
}
|
||||||
|
else if (addRange)
|
||||||
{
|
{
|
||||||
BOOL newSelection;
|
NSUInteger firstIndex = [oldIndexes firstIndex];
|
||||||
|
NSUInteger lastIndex = [oldIndexes lastIndex];
|
||||||
if ((modifiers & (NSShiftKeyMask | NSAlternateKeyMask))
|
NSRange range;
|
||||||
&& _allowsMultipleSelection)
|
|
||||||
{
|
/* We extend the selection to the left or the right of the last selected
|
||||||
newSelection = NO;
|
column. */
|
||||||
}
|
if (columnIndex > [self selectedColumn])
|
||||||
|
{
|
||||||
|
lastIndex = columnIndex;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newSelection = YES;
|
firstIndex = columnIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (([_selectedColumns count] > 0) && (_allowsMultipleSelection == NO)
|
range = NSMakeRange(firstIndex, lastIndex - firstIndex + 1);
|
||||||
&& (newSelection == NO))
|
newIndexes = [NSIndexSet indexSetWithIndexesInRange: range];
|
||||||
{
|
[self selectColumnIndexes: newIndexes byExtendingSelection: YES];
|
||||||
return;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
if ([self _shouldSelectionChange] == NO)
|
[self selectColumnIndexes: newIndexes byExtendingSelection: NO];
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
NSTableColumn *tc = [_tableColumns objectAtIndex: columnIndex];
|
|
||||||
if ([self _shouldSelectTableColumn: tc] == NO)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_selectingColumns == NO)
|
|
||||||
{
|
|
||||||
[self _setSelectingColumns: YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newSelection == YES)
|
|
||||||
{
|
|
||||||
/* No shift or alternate key pressed: clear the old selection */
|
|
||||||
[self selectColumn: columnIndex byExtendingSelection: NO];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Simply add to the old selection */
|
|
||||||
[self selectColumn: columnIndex byExtendingSelection: YES];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue