diff --git a/ChangeLog b/ChangeLog index de7ae874b..a0593d801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-04-10 Eric Wasylishen + + * Headers/AppKit/NSWindow.h + * Source/NSWindow.m: Fix delivery of rightMouseDragged: and otherMouseDragged: + messages. These weren't working because right/otherMouseDragged: would be + called on the _lastView ivar, which was only set on mouse down. + + I replace the _lastView ivar with _lastLeftMouseDownView, _lastRightMouseDownView, + and _lastOtherMouseDownView. Behaviour now matches OS X as far as I can tell. + 2010-04-10 Fred Kiefer * Source/linking.m diff --git a/Headers/AppKit/NSWindow.h b/Headers/AppKit/NSWindow.h index 83645eff0..d6a3f18ba 100644 --- a/Headers/AppKit/NSWindow.h +++ b/Headers/AppKit/NSWindow.h @@ -175,7 +175,9 @@ PACKAGE_SCOPE id _delegate; @protected id _fieldEditor; - id _lastView; + id _lastLeftMouseDownView; + id _lastRightMouseDownView; + id _lastOtherMouseDownView; id _lastDragView; int _lastDragOperationMask; int _windowNum; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index e2a8300d0..3adf48630 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -786,7 +786,9 @@ many times. DESTROY(_defaultButtonCell); DESTROY(_cachedImage); DESTROY(_children); - DESTROY(_lastView); + DESTROY(_lastLeftMouseDownView); + DESTROY(_lastRightMouseDownView); + DESTROY(_lastOtherMouseDownView); DESTROY(_lastDragView); DESTROY(_screen); @@ -3633,9 +3635,9 @@ resetCursorRectsForView(NSView *theView) { v = [_wv hitTest: [theEvent locationInWindow]]; } - if (_lastView) + if (_lastLeftMouseDownView) { - DESTROY(_lastView); + DESTROY(_lastLeftMouseDownView); } // Don't make buttons first responder otherwise they cannot // send actions to the current first responder. @@ -3658,7 +3660,7 @@ resetCursorRectsForView(NSView *theView) } else { - ASSIGN(_lastView, v); + ASSIGN(_lastLeftMouseDownView, v); if (toolTipVisible != nil) { /* Inform the tooltips system that we have had @@ -3683,8 +3685,8 @@ resetCursorRectsForView(NSView *theView) } case NSLeftMouseUp: - v = AUTORELEASE(RETAIN(_lastView)); - DESTROY(_lastView); + v = AUTORELEASE(RETAIN(_lastLeftMouseDownView)); + DESTROY(_lastLeftMouseDownView); if (v == nil) break; [v mouseUp: theEvent]; @@ -3693,24 +3695,32 @@ resetCursorRectsForView(NSView *theView) case NSOtherMouseDown: v = [_wv hitTest: [theEvent locationInWindow]]; + ASSIGN(_lastOtherMouseDownView, v); [v otherMouseDown: theEvent]; _lastPoint = [theEvent locationInWindow]; break; case NSOtherMouseUp: - v = [_wv hitTest: [theEvent locationInWindow]]; + v = AUTORELEASE(RETAIN(_lastOtherMouseDownView)); + DESTROY(_lastOtherMouseDownView); + if (v == nil) + break; [v otherMouseUp: theEvent]; _lastPoint = [theEvent locationInWindow]; break; case NSRightMouseDown: v = [_wv hitTest: [theEvent locationInWindow]]; + ASSIGN(_lastRightMouseDownView, v); [v rightMouseDown: theEvent]; _lastPoint = [theEvent locationInWindow]; break; case NSRightMouseUp: - v = [_wv hitTest: [theEvent locationInWindow]]; + v = AUTORELEASE(RETAIN(_lastRightMouseDownView)); + DESTROY(_lastRightMouseDownView); + if (v == nil) + break; [v rightMouseUp: theEvent]; _lastPoint = [theEvent locationInWindow]; break; @@ -3722,13 +3732,13 @@ resetCursorRectsForView(NSView *theView) switch (type) { case NSLeftMouseDragged: - [_lastView mouseDragged: theEvent]; + [_lastLeftMouseDownView mouseDragged: theEvent]; break; case NSOtherMouseDragged: - [_lastView otherMouseDragged: theEvent]; + [_lastOtherMouseDownView otherMouseDragged: theEvent]; break; case NSRightMouseDragged: - [_lastView rightMouseDragged: theEvent]; + [_lastRightMouseDownView rightMouseDragged: theEvent]; break; default: if (_f.accepts_mouse_moved)