[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSTableView verticalMotionCanBeginDrag stuff
From: |
Matt Rice |
Subject: |
NSTableView verticalMotionCanBeginDrag stuff |
Date: |
Wed, 1 Nov 2006 03:40:31 -0800 (PST) |
heres an initial implementation of the
verticalMotionCanBeginDrag
methods..
couple of questions,
a)since it requires encoding changes, can anyone think
of anything else to do?
b) as currently implemented it is impossible to select
multiple rows through dragging
it selects the current row, and drags it when
mouseDragged on an unselected row, (the same behaviour
as horizontal drag motion currently).
should i change this to only start vertical drags on
already selected rows so vertical motion on unselected
rows allows you to select multiple rows?
other stuff:
the one weird line if (version == currentVersion)
was tracked down to revision 18547 which had a
currentVersion of 3.
I didn't test the encoding code, because gorm doesn't
currently allow you to edit that in NSTableView
inspectors
____________________________________________________________________________________
Low, Low, Low Rates! Check out Yahoo! Messenger's cheap PC-to-Phone call rates
(http://voice.yahoo.com)
Index: Source/NSTableView.m
===================================================================
--- Source/NSTableView.m (revision 24008)
+++ Source/NSTableView.m (working copy)
@@ -64,7 +64,7 @@
#include <math.h>
static NSNotificationCenter *nc = nil;
-static const int currentVersion = 3;
+static const int currentVersion = 4;
static NSRect oldDraggingRect;
static int oldDropRow;
@@ -88,15 +88,17 @@
unsigned int emptySelection:1;
unsigned int multipleSelection:1;
unsigned int columnSelection:1;
- unsigned int __unused:26;
+ unsigned int verticalMotionDrag:1;
+ unsigned int __unused:25;
#else
- unsigned int __unused:26;
+ unsigned int __unused:25;
unsigned int columnSelection:1;
unsigned int multipleSelection:1;
unsigned int emptySelection:1;
unsigned int drawsGrid:1;
unsigned int columnResizing:1;
unsigned int columnOrdering:1;
+ unsigned int verticalMotionDrag:1;
#endif
} GSTableViewFlags;
@@ -3639,17 +3641,19 @@
if (draggingPossible == YES)
{
- if (mouseLocationWin.y - initialLocation.y > 2
- || mouseLocationWin.y - initialLocation.y < -2)
+ if (!_verticalMotionDrag
+ && (mouseLocationWin.y - initialLocation.y > 2
+ || mouseLocationWin.y - initialLocation.y < -2))
{
draggingPossible = NO;
}
- else if (fabs(mouseLocationWin.x - initialLocation.x) >= 4)
+ else if ((fabs(mouseLocationWin.x - initialLocation.x) >= 4)
+ || (_verticalMotionDrag
+ && fabs(mouseLocationWin.y - initialLocation.y
>= 4)))
{
mouseLocationView.x = _bounds.origin.x;
oldRow = currentRow;
- currentRow = [self rowAtPoint: mouseLocationView];
-
+
if (![_selectedRows containsIndex: currentRow])
{
/* Mouse drag in a row that wasn't selected.
@@ -3659,7 +3663,7 @@
_selectedRows,
originalRow,
oldRow,
- currentRow,
+ _clickedRow,
&_selectedRow,
selectionMode);
}
@@ -5183,17 +5187,12 @@
- (void) setVerticalMotionCanBeginDrag: (BOOL)flag
{
- // TODO
- NSLog(@"Method %s is not implemented for class %s",
- "setVerticalMotionCanBeginDrag:", "NSTableView");
+ _verticalMotionDrag = flag;
}
- (BOOL) verticalMotionCanBeginDrag
{
- // TODO
- NSLog(@"Method %s is not implemented for class %s",
- "verticalMotionCanBeginDrag", "NSTableView");
- return NO;
+ return _verticalMotionDrag;
}
/*
@@ -5250,6 +5249,7 @@
tableViewFlags.drawsGrid = [self drawsGrid];
tableViewFlags.columnResizing = [self allowsColumnResizing];
tableViewFlags.columnOrdering = [self allowsColumnReordering];
+ tableViewFlags.verticalMotionDrag = [self verticalMotionCanBeginDrag];
memcpy((void *)&vFlags,(void *)&tableViewFlags,sizeof(unsigned long));
@@ -5282,6 +5282,7 @@
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnResizing];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:
&_allowsColumnReordering];
[aCoder encodeValueOfObjCType: @encode(BOOL) at:
&_autoresizesAllColumnsToFit];
+ [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_verticalMotionDrag];
}
}
@@ -5404,6 +5405,7 @@
[self setDrawsGrid: tableViewFlags.drawsGrid];
[self setAllowsColumnResizing: tableViewFlags.columnResizing];
[self setAllowsColumnReordering: tableViewFlags.columnOrdering];
+ [self setVerticalMotionCanBeginDrag:
tableViewFlags.verticalMotionDrag];
}
_numberOfColumns = [columns count];
@@ -5420,6 +5422,7 @@
int version = [aDecoder versionForClassName:
@"NSTableView"];
id aDelegate;
+ _verticalMotionDrag = NO;
_dataSource = [aDecoder decodeObject];
_tableColumns = RETAIN([aDecoder decodeObject]);
@@ -5446,7 +5449,7 @@
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_allowsEmptySelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_allowsColumnSelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_allowsColumnResizing];
- if (version == currentVersion)
+ if (version >= 3)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_allowsColumnReordering];
}
@@ -5454,7 +5457,12 @@
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_autoresizesAllColumnsToFit];
}
-
+
+ if (version >= 4)
+ {
+ [aDecoder decodeValueOfObjCType: @encode(BOOL) at:
&_verticalMotionDrag];
+ }
+
ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]);
ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]);
if (_numberOfColumns)
Index: Headers/AppKit/NSTableView.h
===================================================================
--- Headers/AppKit/NSTableView.h (revision 24006)
+++ Headers/AppKit/NSTableView.h (working copy)
@@ -90,6 +90,7 @@
NSCell *_editedCell;
BOOL _autosaveTableColumns;
NSString *_autosaveName;
+ BOOL _verticalMotionDrag;
/*
* Ivars Acting as Cache
- NSTableView verticalMotionCanBeginDrag stuff,
Matt Rice <=