Improve autoscroll when drag-selecting outside viewport

When user drag-selects and moves mouse outside the viewport, we do not want to use ‘ensureSelectionIsInVisibleArea:’ because that method looks only on the selection, particularly the non-anchored end-point (and works differently for unanchored selections). Instead we want to scroll the point corresponding to the mouse position inside the viewport.

Fixes #475.
This commit is contained in:
Allan Odgaard
2013-01-28 12:33:07 +01:00
parent 7831a40b23
commit 456209730d

View File

@@ -529,6 +529,9 @@ static std::string shell_quote (std::vector<std::string> paths)
- (void)ensureSelectionIsInVisibleArea:(id)sender
{
if(([NSEvent pressedMouseButtons] & 1) == 1) // User is drag-selecting
return;
ng::range_t range = editor->ranges().last();
CGRect r = layout->rect_at_index(range.last);
CGRect s = [self visibleRect];
@@ -2611,6 +2614,8 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac
ng::ranges_t s = editor->ranges();
s.last() = range.last();
editor->set_selections(s);
[self autoscroll:anEvent];
}
- (void)startDragForEvent:(NSEvent*)anEvent