Skip to content

Commit

Permalink
Fix cursor positioning while dragging the mouse
Browse files Browse the repository at this point in the history
The cursor is only moved if it is not a dragging operation. To make that
possible the code was moved from mouseDownImpl to mouseUp. Thanks to
darthAndrus on the google code issue tracker for this suggestion.
  • Loading branch information
boretom committed Mar 15, 2012
1 parent b919985 commit 6c57a28
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions PTYTextView.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2895,18 +2895,8 @@ - (BOOL)mouseDownImpl:(NSEvent*)event
// extend the selection. // extend the selection.
[self extendSelectionToX:x y:y]; [self extendSelectionToX:x y:y];
// startX and endX may be reversed, but mouseUp fixes it. // startX and endX may be reversed, but mouseUp fixes it.

if (altPressed && !cmdPressed) {
[self placeCursorOnCurrentLineWithEvent:event];
return NO;
}
} else if (startX > -1 && } else if (startX > -1 &&
[self _isCharSelectedInRow:y col:x checkOld:NO]) { [self _isCharSelectedInRow:y col:x checkOld:NO]) {
if (altPressed && !cmdPressed) {
[self placeCursorOnCurrentLineWithEvent:event];
return NO;
}

// not holding down shift key but there is an existing selection. // not holding down shift key but there is an existing selection.
// Possibly a drag coming up. // Possibly a drag coming up.
mouseDownOnSelection = YES; mouseDownOnSelection = YES;
Expand All @@ -2916,10 +2906,6 @@ - (BOOL)mouseDownImpl:(NSEvent*)event
endX = startX = x; endX = startX = x;
endY = startY = y; endY = startY = y;
[self setSelectionTime]; [self setSelectionTime];

if (altPressed && !cmdPressed) {
[self placeCursorOnCurrentLineWithEvent:event];
}
} }
} else if (clickCount == 2) { } else if (clickCount == 2) {
int tmpX1, tmpY1, tmpX2, tmpY2; int tmpX1, tmpY1, tmpX2, tmpY2;
Expand Down Expand Up @@ -3117,10 +3103,15 @@ - (void)mouseUp:(NSEvent *)event
!mouseDragged && !mouseDragged &&
!([event modifierFlags] & NSShiftKeyMask)) { !([event modifierFlags] & NSShiftKeyMask)) {
// Just a click in the window. // Just a click in the window.

BOOL altPressed = ([event modifierFlags] & NSAlternateKeyMask) != 0;
if (altPressed && !cmdPressed) {
[self placeCursorOnCurrentLineWithEvent:event];
}

startX=-1; startX=-1;
if (cmdPressed && if (cmdPressed &&
[[PreferencePanel sharedInstance] cmdSelection]) { [[PreferencePanel sharedInstance] cmdSelection]) {
BOOL altPressed = ([event modifierFlags] & NSAlternateKeyMask) != 0;
if (altPressed) { if (altPressed) {
[self openTargetInBackgroundWithEvent:event]; [self openTargetInBackgroundWithEvent:event];
} else { } else {
Expand Down

0 comments on commit 6c57a28

Please sign in to comment.