Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: ui/app_list/cocoa/apps_grid_controller.mm

Issue 15648003: Fix keyboard navigation in app launcher (OSX) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge http://crrev.com/15661002 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/app_list/cocoa/apps_grid_controller.mm
diff --git a/ui/app_list/cocoa/apps_grid_controller.mm b/ui/app_list/cocoa/apps_grid_controller.mm
index fc101554647474ddaeb572f90343581a779539b2..01e38cb7c11e8068f392c73d6b28ebdab2bbdf74 100644
--- a/ui/app_list/cocoa/apps_grid_controller.mm
+++ b/ui/app_list/cocoa/apps_grid_controller.mm
@@ -535,9 +535,18 @@ class AppsGridDelegateBridge : public ui::ListModelObserver {
return YES;
}
- if ((indexDelta < 0 && static_cast<NSUInteger>(-indexDelta) > oldIndex) ||
- oldIndex + indexDelta >= [items_ count]) {
+ // Can't select a negative index.
+ if (indexDelta < 0 && static_cast<NSUInteger>(-indexDelta) > oldIndex)
return NO;
+
+ // Can't select an index greater or equal to the number of items.
+ if (oldIndex + indexDelta >= [items_ count]) {
+ if (visiblePage_ == [pages_ count] - 1)
+ return NO;
+
+ // If we're not on the last page, then select the last item.
+ [self selectItemAtIndex:[items_ count] - 1];
+ return YES;
}
[self selectItemAtIndex:oldIndex + indexDelta];
@@ -561,17 +570,34 @@ class AppsGridDelegateBridge : public ui::ListModelObserver {
return YES;
}
- if (command == @selector(moveLeft:))
- return [self moveSelectionByDelta:-1];
+ NSUInteger oldIndex = [self selectedItemIndex];
+ // If nothing is currently selected, select the first item on the page.
+ if (oldIndex == NSNotFound) {
+ [self selectItemAtIndex:visiblePage_ * kItemsPerPage];
+ return YES;
+ }
+
+ if (command == @selector(moveLeft:)) {
+ return oldIndex % kFixedColumns == 0 ?
+ [self moveSelectionByDelta:-kItemsPerPage + kFixedColumns - 1] :
+ [self moveSelectionByDelta:-1];
+ }
- if (command == @selector(moveRight:))
- return [self moveSelectionByDelta:1];
+ if (command == @selector(moveRight:)) {
+ return oldIndex % kFixedColumns == kFixedColumns - 1 ?
+ [self moveSelectionByDelta:+kItemsPerPage - kFixedColumns + 1] :
+ [self moveSelectionByDelta:1];
+ }
- if (command == @selector(moveUp:))
- return [self moveSelectionByDelta:-kFixedColumns];
+ if (command == @selector(moveUp:)) {
+ return oldIndex / kFixedColumns % kFixedRows == 0 ?
+ NO : [self moveSelectionByDelta:-kFixedColumns];
+ }
- if (command == @selector(moveDown:))
- return [self moveSelectionByDelta:kFixedColumns];
+ if (command == @selector(moveDown:)) {
+ return oldIndex / kFixedColumns % kFixedRows == kFixedRows - 1 ?
+ NO : [self moveSelectionByDelta:kFixedColumns];
+ }
if (command == @selector(pageUp:) ||
command == @selector(scrollPageUp:))
« no previous file with comments | « no previous file | ui/app_list/cocoa/apps_grid_controller_unittest.mm » ('j') | ui/app_list/cocoa/apps_grid_controller_unittest.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698