Permalink
Browse files

Fix cursor positioning while dragging the mouse

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...
1 parent b919985 commit 6c57a289e9fc035fd8e5ada0da23f79ba6f9e703 @boretom boretom committed Mar 15, 2012
Showing with 6 additions and 15 deletions.
  1. +6 −15 PTYTextView.m
View
21 PTYTextView.m
@@ -2895,18 +2895,8 @@ - (BOOL)mouseDownImpl:(NSEvent*)event
// extend the selection.
[self extendSelectionToX:x y:y];
// startX and endX may be reversed, but mouseUp fixes it.
-
- if (altPressed && !cmdPressed) {
- [self placeCursorOnCurrentLineWithEvent:event];
- return NO;
- }
} else if (startX > -1 &&
[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.
// Possibly a drag coming up.
mouseDownOnSelection = YES;
@@ -2916,10 +2906,6 @@ - (BOOL)mouseDownImpl:(NSEvent*)event
endX = startX = x;
endY = startY = y;
[self setSelectionTime];
-
- if (altPressed && !cmdPressed) {
- [self placeCursorOnCurrentLineWithEvent:event];
- }
}
} else if (clickCount == 2) {
int tmpX1, tmpY1, tmpX2, tmpY2;
@@ -3117,10 +3103,15 @@ - (void)mouseUp:(NSEvent *)event
!mouseDragged &&
!([event modifierFlags] & NSShiftKeyMask)) {
// Just a click in the window.
+
+ BOOL altPressed = ([event modifierFlags] & NSAlternateKeyMask) != 0;
+ if (altPressed && !cmdPressed) {
+ [self placeCursorOnCurrentLineWithEvent:event];
+ }
+
startX=-1;
if (cmdPressed &&
[[PreferencePanel sharedInstance] cmdSelection]) {
- BOOL altPressed = ([event modifierFlags] & NSAlternateKeyMask) != 0;
if (altPressed) {
[self openTargetInBackgroundWithEvent:event];
} else {

0 comments on commit 6c57a28

Please sign in to comment.