[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m
From: |
Matt Rice |
Subject: |
Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m |
Date: |
Sun, 5 Jun 2005 17:48:10 -0700 (PDT) |
--- Fred Kiefer <address@hidden> wrote:
> Matt Rice wrote:
> > --- Enrico Sersale <address@hidden> wrote:
> >>Just to be more precise :) ... I'm not referring
> to
> >>this; I've fixed it implementing -copyWithZone: in
> >>my cell class when I've seen that gworkspace
> >>segfaults trying to release an ivar of this class.
> >>The real problem is that it is not possible
> anymore
> >>to start a drag from a cell (this is visible in
> >>GNUMail, too). Making -startTrackingAt:inView: to
> >>return NO in the cell class fixes this problem
> too,
> >>but I think that there is something wrong in
> >>-mouseDown: because, before theese changes, both
> the
> >>apps worked well.
> >
> > indeed I don't think that should be required
> either.
> > (though looking at the docs i noticed that
> > -startTrackingAt:inView:... returns NO if the view
> > doesn't send actions on dragging or periodic
> events
> >
> > it isn't clear whether this affects the return
> value
> > of trackMouse:inRect:...
> >
> > anyhow a little testing shows you are correct.
> >
> > this changes the behaviour of trackMouse:inRect:..
> > slightly to cope with an event that happened in
> the pa
> >
> > in a dragging source table view
> > trackMouse:mouseDownEvent will be sent after the
> mouse
> > has gone up (when it is clear that no dragging has
> > been started).. though this severely limits the
> cells
> > which will work with one
> >
> > sure isn't pretty though, that's probably
> fixable..
> >
>
> This is a rather huge patch, could you please
> describe in more detail,
> what you are aiming at with it? What did you test
> and how does MacOSX
> differ from the current GNUstep behaviour?
it differs quite a bit but I didn't test very much..
just what happens wrt dragging source table views wrt
trackMouse:...
(which i'll reiterate) they don't send the mouse down
until mouse up has been sent and it is determined that
a drag operation hasn't started.
also that starting dragging operation in no way
affects the selection, though (to state the obvious...
starting a dragging operation on a selection drags the
selection). I personally prefer the GNUstep behaviour
of starting a drag operation modifies the selection.
so the trackMouse: code has basically been moved into
3 places...
1) after it has been determined there is no dragging
operation in progress..
2) when the delegate returns no for
shouldEditTableColumn: in a double click event
and this was changed a bit to handle more than just
double click but >1 so that each successive click
for instance with a switch button changes the state.
3) if table view isn't a dragging source send
trackMouse:... immediately
and the double click code brought into the loop (since
its looping over the events -mouseDown: was not
getting called with a clickCount over 1...)
and after the trackMouse:... code set the
getNextEvent: flag if the current event isn't the
lastEvent so that it'll loop again and handle any
mouse down event so next time mouseDown: is called it
doesn't think we're extending the selection or
something... this happens for all but the first case,
where it doesn't matter since we're at a mouse up
event and it'll never get to the point of looking at
the getNextEvent flag.
> Most of what changed looks like just a reformatting,
> which should be
> harmless, but this makes it hard to see the actual
> change itself. Would
> it be possible to provide a different patch, which
> tries to keep the old
> formatting (perhaps by using some dummy {}
> combination)? Even the old
> mouseDown: method here was unreadable, but the patch
> realy is
> incomprehensible for me in its current form.
>
yes sorry about that, I accidentally overwrote my code
i had before the formatting changes, and wasn't
exactly ecstatic about that...
__________________________________
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
Index: NSTableView.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSTableView.m,v
retrieving revision 1.118
diff -u -r1.118 NSTableView.m
--- NSTableView.m 30 May 2005 17:01:21 -0000 1.118
+++ NSTableView.m 6 Jun 2005 00:12:24 -0000
@@ -3332,7 +3332,32 @@
{
NSPoint initialLocation = [theEvent locationInWindow];
NSPoint location;
- int clickCount;
+ // Selection
+ unsigned int modifiers = [theEvent modifierFlags];
+ unsigned int eventMask = (NSLeftMouseUpMask
+ | NSLeftMouseDownMask
+ | NSLeftMouseDraggedMask
+ | NSPeriodicMask);
+ unsigned selectionMode;
+ NSPoint mouseLocationWin;
+ NSPoint mouseLocationView;
+ NSDate *distantFuture = [NSDate distantFuture];
+ NSEvent *lastEvent;
+ NSIndexSet *oldSelectedRows;
+ BOOL startedPeriodicEvents = NO;
+ BOOL mouseUp = NO;
+ BOOL done = NO;
+ BOOL mouseMoved = NO;
+ BOOL draggingPossible = [self _isDraggingSource];
+ BOOL getNextEvent = YES;
+ NSRect visibleRect = [self convertRect: [self visibleRect]
+ toView: nil];
+ float minYVisible = NSMinY (visibleRect);
+ float maxYVisible = NSMaxY (visibleRect);
+ float oldPeriod = 0;
+ int originalRow;
+ int oldRow = -1;
+ int currentRow = -1;
// Pathological case -- ignore mouse down
if ((_numberOfRows == 0) || (_numberOfColumns == 0))
@@ -3341,70 +3366,12 @@
return;
}
- clickCount = [theEvent clickCount];
- if (clickCount > 2)
- {
- return;
- }
-
// Determine row and column which were clicked
location = [self convertPoint: initialLocation fromView: nil];
_clickedRow = [self rowAtPoint: location];
+ originalRow = _clickedRow;
_clickedColumn = [self columnAtPoint: location];
- if (clickCount == 2)
- {
- // Double-click event
- NSTableColumn *tb;
-
- if ([self isRowSelected: _clickedRow] == NO)
- {
- return;
- }
-
- tb = [_tableColumns objectAtIndex: _clickedColumn];
- if (([tb isEditable] == NO) ||
- ([self _shouldEditTableColumn: tb
- row: _clickedRow] == NO))
- {
- // Send double-action but don't edit
- [self sendAction: _doubleAction to: _target];
- }
- else
- {
- // It is OK to edit column. Go on, do it.
- [self editColumn: _clickedColumn row: _clickedRow
- withEvent: theEvent select: YES];
- }
- }
- else
- {
- // Selection
- unsigned int modifiers = [theEvent modifierFlags];
- unsigned int eventMask = (NSLeftMouseUpMask
- | NSLeftMouseDownMask
- | NSLeftMouseDraggedMask
- | NSPeriodicMask);
- unsigned selectionMode;
- NSPoint mouseLocationWin;
- NSPoint mouseLocationView;
- NSDate *distantFuture = [NSDate distantFuture];
- NSEvent *lastEvent;
- NSIndexSet *oldSelectedRows;
- BOOL startedPeriodicEvents = NO;
- BOOL mouseUp = NO;
- BOOL done = NO;
- BOOL mouseMoved = NO;
- BOOL draggingPossible = [self _isDraggingSource];
- NSRect visibleRect = [self convertRect: [self visibleRect]
- toView: nil];
- float minYVisible = NSMinY (visibleRect);
- float maxYVisible = NSMaxY (visibleRect);
- float oldPeriod = 0;
- int originalRow = _clickedRow;
- int oldRow = -1;
- int currentRow = -1;
-
selectionMode = 0;
if (_allowsMultipleSelection == YES)
{
@@ -3451,57 +3418,6 @@
mouseLocationView = location;
lastEvent = theEvent;
- if ([self mouse: mouseLocationView inRect: _bounds])
- {
- NSTableColumn *tb;
- NSCell *cell;
- NSRect cellFrame;
- id originalValue;
-
- // Prepare the cell
- tb = [_tableColumns objectAtIndex: _clickedColumn];
- // It is unclear, if we should copy the cell here, as we do on
editing.
- cell = [tb dataCellForRow: _clickedRow];
- originalValue = RETAIN([self _objectValueForTableColumn:tb
row:_clickedRow]);
- [cell setObjectValue: originalValue];
- cellFrame = [self frameOfCellAtColumn: _clickedColumn
- row: _clickedRow];
- [cell setHighlighted: YES];
- [self setNeedsDisplayInRect: cellFrame];
- /* give delegate a chance to i.e set target */
- [self _willDisplayCell: cell
- forTableColumn: tb
- row: _clickedRow];
- if ([cell trackMouse: lastEvent
- inRect: cellFrame
- ofView: self
- untilMouseUp: [[cell class] prefersTrackingUntilMouseUp]])
- {
- id newValue = [cell objectValue];
-
- if ([tb isEditable] && ![originalValue isEqual: newValue])
- {
- [self _setObjectValue: newValue
- forTableColumn: tb
- row: _clickedRow];
- }
- done = YES;
- currentRow = _clickedRow;
- computeNewSelection(self,
- oldSelectedRows,
- _selectedRows,
- originalRow,
- oldRow,
- currentRow,
- &_selectedRow,
- selectionMode);
- }
- RELEASE(originalValue);
- [cell setHighlighted: NO];
- [self setNeedsDisplayInRect: cellFrame];
- lastEvent = [NSApp currentEvent];
- }
-
while (done != YES)
{
/*
@@ -3534,6 +3450,54 @@
{
shouldComputeNewSelection = YES;
}
+
+ if (draggingPossible == YES)
+ {
+ NSTableColumn *tb;
+ NSCell *cell;
+ NSRect cellFrame;
+ id originalValue;
+
+ tb = [_tableColumns objectAtIndex: _clickedColumn];
+ cell = [tb dataCellForRow: _clickedRow];
+ originalValue = RETAIN([self _objectValueForTableColumn:tb
+ row:_clickedRow]);
+ [cell setObjectValue: originalValue];
+ cellFrame = [self frameOfCellAtColumn: _clickedColumn
+ row: _clickedRow];
+ [cell setHighlighted: YES];
+ [self setNeedsDisplayInRect: cellFrame];
+ /* give delegate a chance to i.e set target */
+ [self _willDisplayCell: cell
+ forTableColumn: tb
+ row: _clickedRow];
+ /* send the orignal mouse down event
+ * NSCell -trackMouse:... needs to be able to handle
+ * mouseUp being the -[NSApp currentEvent]
+ * this also means that cells which are continuous or
+ * rely on NSLeftMouseDragged wont work if dragging is
+ * possible.
+ */
+ if ([cell trackMouse: theEvent
+ inRect: cellFrame
+ ofView: self
+ untilMouseUp:[[cell class]
+ prefersTrackingUntilMouseUp]])
+ {
+ id newValue = [cell objectValue];
+
+ if ([tb isEditable]
+ && ![originalValue isEqual: newValue])
+ {
+ [self _setObjectValue: newValue
+ forTableColumn: tb
+ row: _clickedRow];
+ }
+ }
+ RELEASE(originalValue);
+ [cell setHighlighted: NO];
+ [self setNeedsDisplayInRect: cellFrame];
+ }
}
else
{
@@ -3545,6 +3509,74 @@
case NSLeftMouseDown:
case NSLeftMouseDragged:
+ if ([lastEvent type] == NSLeftMouseDown
+ && [lastEvent clickCount] > 1)
+ {
+ // Double-click event
+ NSTableColumn *tb;
+
+ if ([self isRowSelected: _clickedRow] == NO)
+ {
+ return;
+ }
+
+ tb = [_tableColumns objectAtIndex: _clickedColumn];
+ if (([tb isEditable] == NO) ||
+ ([self _shouldEditTableColumn: tb
+ row: _clickedRow] == NO))
+ {
+ // Send double-action but don't edit
+ NSTableColumn *tb;
+ NSCell *cell;
+ NSRect cellFrame;
+ id originalValue;
+
+ tb = [_tableColumns objectAtIndex: _clickedColumn];
+ cell = [tb dataCellForRow: _clickedRow];
+ originalValue = RETAIN([self _objectValueForTableColumn:tb
+ row:_clickedRow]);
+ [cell setObjectValue: originalValue];
+ cellFrame = [self frameOfCellAtColumn: _clickedColumn
+ row: _clickedRow];
+ [cell setHighlighted: YES];
+ [self setNeedsDisplayInRect: cellFrame];
+ /* give delegate a chance to i.e set target */
+ [self _willDisplayCell: cell
+ forTableColumn: tb
+ row: _clickedRow];
+ if ([cell trackMouse: theEvent
+ inRect: cellFrame
+ ofView: self
+ untilMouseUp:[[cell class]
+ prefersTrackingUntilMouseUp]])
+ {
+ id newValue = [cell objectValue];
+
+ if ([tb isEditable] &&
+ ![originalValue isEqual: newValue])
+ {
+ [self _setObjectValue: newValue
+ forTableColumn: tb
+ row: _clickedRow];
+ }
+ }
+ RELEASE(originalValue);
+ [cell setHighlighted: NO];
+ [self setNeedsDisplayInRect: cellFrame];
+ getNextEvent = (lastEvent == [NSApp currentEvent]);
+ [self sendAction: _doubleAction to: _target];
+ }
+ else
+ {
+ // It is OK to edit column. Go on, do it.
+ [self editColumn: _clickedColumn
+ row: _clickedRow
+ withEvent: theEvent
+ select: YES];
+ }
+ }
+ else
+ {
mouseLocationWin = [lastEvent locationInWindow];
mouseLocationView = [self convertPoint: mouseLocationWin
fromView: nil];
@@ -3635,6 +3667,10 @@
else if ((mouseLocationWin.y > minYVisible)
&& (mouseLocationWin.y < maxYVisible))
{
+ NSTableColumn *tb;
+ NSCell *cell;
+ NSRect cellFrame;
+ id originalValue;
// mouse dragged within table
if (startedPeriodicEvents == YES)
{
@@ -3651,6 +3687,39 @@
{
shouldComputeNewSelection = YES;
}
+ tb = [_tableColumns objectAtIndex: _clickedColumn];
+ cell = [tb dataCellForRow: _clickedRow];
+ originalValue = RETAIN([self _objectValueForTableColumn:tb
+ row:_clickedRow]);
+ [cell setObjectValue: originalValue];
+ cellFrame = [self frameOfCellAtColumn: _clickedColumn
+ row: _clickedRow];
+ [cell setHighlighted: YES];
+ [self setNeedsDisplayInRect: cellFrame];
+ /* give delegate a chance to i.e set target */
+ [self _willDisplayCell: cell
+ forTableColumn: tb
+ row: _clickedRow];
+ if ([cell trackMouse: theEvent
+ inRect: cellFrame
+ ofView: self
+ untilMouseUp:[[cell class]
+ prefersTrackingUntilMouseUp]])
+ {
+ id newValue = [cell objectValue];
+
+ if ([tb isEditable] &&
+ ![originalValue isEqual: newValue])
+ {
+ [self _setObjectValue: newValue
+ forTableColumn: tb
+ row: _clickedRow];
+ }
+ }
+ RELEASE(originalValue);
+ [cell setHighlighted: NO];
+ [self setNeedsDisplayInRect: cellFrame];
+ getNextEvent = (lastEvent == [NSApp currentEvent]);
}
else
{
@@ -3678,6 +3747,7 @@
else
mouseUp = YES;
}
+ }
break;
case NSPeriodic:
if (mouseUp == NO)
@@ -3723,10 +3793,17 @@
}
if (done == NO)
{
+ if (getNextEvent == YES)
lastEvent = [NSApp nextEventMatchingMask: eventMask
untilDate: distantFuture
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
+ else
+ {
+ lastEvent = [NSApp currentEvent];
+ getNextEvent = YES;
+
+ }
}
DESTROY(arp);
}
@@ -3752,7 +3829,6 @@
[self sendAction: _action to: _target];
}
return;
- }
}
/*
Index: NSCell.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSCell.m,v
retrieving revision 1.170
diff -u -r1.170 NSCell.m
--- NSCell.m 26 May 2005 02:52:43 -0000 1.170
+++ NSCell.m 6 Jun 2005 00:12:27 -0000
@@ -1362,8 +1362,10 @@
NSEventType eventType;
BOOL pointIsInCell;
unsigned periodCount = 0;
-
- theEvent = [theApp nextEventMatchingMask: event_mask
+ if (theEvent != [NSApp currentEvent])
+ theEvent = [NSApp currentEvent];
+ else
+ theEvent = [theApp nextEventMatchingMask: event_mask
untilDate: nil
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Matt Rice, 2005/06/04
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Fred Kiefer, 2005/06/05
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m,
Matt Rice <=
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Fred Kiefer, 2005/06/06
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Fred Kiefer, 2005/06/19
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Quentin Mathé, 2005/06/20
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Quentin Mathé, 2005/06/20
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Fred Kiefer, 2005/06/21
- Re: [Gnustep-cvs] gnustep/core/gui ChangeLog Source/NSTableView.m, Quentin Mathé, 2005/06/24