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

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: Sync and rebase 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
« no previous file with comments | « no previous file | ui/app_list/cocoa/apps_grid_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 795979adc0f75bbc1ffda4de2d8106d87588a1cc..6a47ed4317824f6646ce51cbe1b316b545626e84 100644
--- a/ui/app_list/cocoa/apps_grid_controller.mm
+++ b/ui/app_list/cocoa/apps_grid_controller.mm
@@ -603,9 +603,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];
@@ -629,17 +638,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698