(-mouseDown:): Send our action if we get a single, simple (no drag) click.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18837 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2004-03-12 14:32:57 +00:00
parent 8fa364b385
commit 2f8484ff24
2 changed files with 28 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2004-03-12 15:30 Alexander Malmberg <alexander@malmberg.org>
* Source/NSTableView.m (-mouseDown:): Send our action if we get
a single, simple (no drag) click.
2004-03-08 19:19 Alexander Malmberg <alexander@malmberg.org> 2004-03-08 19:19 Alexander Malmberg <alexander@malmberg.org>
* Source/NSPageLayout.m (-readPrintInfo): Move declarations before * Source/NSPageLayout.m (-readPrintInfo): Move declarations before

View file

@ -4245,13 +4245,14 @@ byExtendingSelection: (BOOL)flag
toView: nil]; toView: nil];
float minYVisible = NSMinY (visibleRect); float minYVisible = NSMinY (visibleRect);
float maxYVisible = NSMaxY (visibleRect); float maxYVisible = NSMaxY (visibleRect);
BOOL mouseMoved = NO;
/* We have three zones of speed. /* We have three zones of speed.
0 - 50 pixels: period 0.2 <zone 1> 0 - 50 pixels: period 0.2 <zone 1>
50 - 100 pixels: period 0.1 <zone 2> 50 - 100 pixels: period 0.1 <zone 2>
100 - 150 pixels: period 0.01 <zone 3> */ 100 - 150 pixels: period 0.01 <zone 3> */
float oldPeriod = 0; float oldPeriod = 0;
inline float computePeriod () inline float computePeriod(void)
{ {
float distance = 0; float distance = 0;
@ -4373,9 +4374,17 @@ byExtendingSelection: (BOOL)flag
} }
done = YES; done = YES;
break; break;
case NSLeftMouseDown: case NSLeftMouseDown:
case NSLeftMouseDragged: case NSLeftMouseDragged:
mouseLocationWin = [lastEvent locationInWindow]; mouseLocationWin = [lastEvent locationInWindow];
if (fabs(mouseLocationWin.x - initialLocation.x) > 1
|| fabs(mouseLocationWin.y - initialLocation.y) > 1)
{
mouseMoved = YES;
}
if (draggingPossible == YES) if (draggingPossible == YES)
{ {
if (mouseLocationWin.y - initialLocation.y > 2 if (mouseLocationWin.y - initialLocation.y > 2
@ -4545,7 +4554,18 @@ byExtendingSelection: (BOOL)flag
sortedArrayUsingSelector: @selector(compare:)]] == NO) sortedArrayUsingSelector: @selector(compare:)]] == NO)
{ {
[self _postSelectionDidChangeNotification]; [self _postSelectionDidChangeNotification];
} }
else if (!mouseMoved)
{
/*
_clickedRow and _clickedColumn are already set at the start of
this function.
TODO: should we ask the data source/column for the cell for this
row/column and check whether it has its own action/target?
*/
[self sendAction: _action to: _target];
}
return; return;
} }