From d39849b297bfeed3f3d4fc143297f183c35d2002 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Thu, 21 Jun 2012 19:24:22 +0100 Subject: [PATCH] Improve token field keyboard navigation when tokens are selected. If one or more token is selected and the left arrow key is pressed, collapse the selection to the left of the first selected token. Similarly, on right arrow key collapse to the right of the last token. Note that shift-left and shift-right have no effect if the first or last token respectively in the field are already selected. --- AppKit/CPTokenField.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 0cff8e262..d306052e9 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -725,7 +725,7 @@ var CPScrollDestinationNone = 0, - (void)moveLeft:(id)sender { // Left arrow - if (_selectedRange.location > 0 && CPTokenFieldDOMInputElement.value == "") + if ((_selectedRange.location > 0 || _selectedRange.length) && CPTokenFieldDOMInputElement.value == "") { if (_selectedRange.length) // Simply collapse the range. @@ -762,7 +762,7 @@ var CPScrollDestinationNone = 0, - (void)moveRight:(id)sender { // Right arrow - if (_selectedRange.location < [[self _tokens] count] && CPTokenFieldDOMInputElement.value == "") + if ((_selectedRange.location < [[self _tokens] count] || _selectedRange.length) && CPTokenFieldDOMInputElement.value == "") { if (_selectedRange.length) {