Commit 9b663ecf authored by Mike Pinkerton's avatar Mike Pinkerton Committed by Commit Bot

Add additional keyboard shortcuts for next/prev tab.

Add cmd-{/} keyboard shortcuts to match Mac desktop, in addition to the
commands that are already there. Additionally fix up the directionality
to take RTL into account.

BUG=988313

Change-Id: I9b8b69c30a85f0dbc9e38a5d8a6b72a97355d06f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427422
Auto-Submit: Mike Pinkerton <pinkerton@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810322}
parent 5200de26
...@@ -1015,6 +1015,12 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex ...@@ -1015,6 +1015,12 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex
<message name="IDS_IOS_KEYBOARD_REOPEN_CLOSED_TAB" desc="Title of the keyboard shortcut to reopen a recently closed tab. [Length: 20 em] [iOS only]"> <message name="IDS_IOS_KEYBOARD_REOPEN_CLOSED_TAB" desc="Title of the keyboard shortcut to reopen a recently closed tab. [Length: 20 em] [iOS only]">
Reopen Closed Tab Reopen Closed Tab
</message> </message>
<message name="IDS_IOS_KEYBOARD_NEXT_TAB" desc="Title of the keyboard shortcut to switch to the next tab in the tab strip. [Length: 20 em] [iOS only]">
Next Tab
</message>
<message name="IDS_IOS_KEYBOARD_PREVIOUS_TAB" desc="Title of the keyboard shortcut to switch to the previous tab in the tab strip. [Length: 20 em] [iOS only]">
Previous Tab
</message>
<message name="IDS_IOS_LONG_PRESS_TOOLBAR_IPH_PROMOTION_TEXT" desc="Text for the LongPress Toolbar Tip in-product help promotion, explaining that the user can long press on the toolbar's button to display more options. [iOS only]"> <message name="IDS_IOS_LONG_PRESS_TOOLBAR_IPH_PROMOTION_TEXT" desc="Text for the LongPress Toolbar Tip in-product help promotion, explaining that the user can long press on the toolbar's button to display more options. [iOS only]">
Touch &amp; hold for more tab options Touch &amp; hold for more tab options
</message> </message>
......
ce0e6afda38f6e05303f521b39b9cc4128133723
\ No newline at end of file
ce0e6afda38f6e05303f521b39b9cc4128133723
\ No newline at end of file
...@@ -66,6 +66,25 @@ ...@@ -66,6 +66,25 @@
}; };
} }
// Blocks for next/previous tab.
void (^focusTabLeft)();
void (^focusTabRight)();
if (useRTLLayout) {
focusTabLeft = ^{
[weakConsumer focusNextTab];
};
focusTabRight = ^{
[weakConsumer focusPreviousTab];
};
} else {
focusTabLeft = ^{
[weakConsumer focusPreviousTab];
};
focusTabRight = ^{
[weakConsumer focusNextTab];
};
}
// New tab blocks. // New tab blocks.
void (^newTab)() = ^{ void (^newTab)() = ^{
OpenNewTabCommand* newTabCommand = [OpenNewTabCommand command]; OpenNewTabCommand* newTabCommand = [OpenNewTabCommand command];
...@@ -169,6 +188,44 @@ ...@@ -169,6 +188,44 @@
[weakDispatcher closeCurrentTab]; [weakDispatcher closeCurrentTab];
} }
}], }],
]];
// Deal with the multiple next/previous tab commands we have, only one pair
// of which appears in the HUD. Take RTL into account for the direction.
const int tabLeftDescriptionID = useRTLLayout
? IDS_IOS_KEYBOARD_NEXT_TAB
: IDS_IOS_KEYBOARD_PREVIOUS_TAB;
const int tabRightDescriptionID = useRTLLayout
? IDS_IOS_KEYBOARD_PREVIOUS_TAB
: IDS_IOS_KEYBOARD_NEXT_TAB;
NSString* tabLeftTitle = l10n_util::GetNSStringWithFixup(
tabLeftDescriptionID);
NSString* tabRightTitle = l10n_util::GetNSStringWithFixup(
tabRightDescriptionID);
[keyCommands addObjectsFromArray:@[
[UIKeyCommand
cr_keyCommandWithInput:UIKeyInputLeftArrow
modifierFlags:UIKeyModifierCommand | UIKeyModifierAlternate
title:tabLeftTitle
action:focusTabLeft],
[UIKeyCommand
cr_keyCommandWithInput:UIKeyInputRightArrow
modifierFlags:UIKeyModifierCommand | UIKeyModifierAlternate
title:tabRightTitle
action:focusTabRight],
[UIKeyCommand
cr_keyCommandWithInput:@"{"
modifierFlags:UIKeyModifierCommand
title:nil
action:focusTabLeft],
[UIKeyCommand
cr_keyCommandWithInput:@"}"
modifierFlags:UIKeyModifierCommand
title:nil
action:focusTabRight],
]];
[keyCommands addObjectsFromArray:@[
[UIKeyCommand [UIKeyCommand
cr_keyCommandWithInput:@"d" cr_keyCommandWithInput:@"d"
modifierFlags:UIKeyModifierCommand modifierFlags:UIKeyModifierCommand
...@@ -339,20 +396,6 @@ ...@@ -339,20 +396,6 @@
action:^{ action:^{
focusTab([weakConsumer tabsCount] - 1); focusTab([weakConsumer tabsCount] - 1);
}], }],
[UIKeyCommand
cr_keyCommandWithInput:UIKeyInputLeftArrow
modifierFlags:UIKeyModifierCommand | UIKeyModifierAlternate
title:nil
action:^{
[weakConsumer focusPreviousTab];
}],
[UIKeyCommand
cr_keyCommandWithInput:UIKeyInputRightArrow
modifierFlags:UIKeyModifierCommand | UIKeyModifierAlternate
title:nil
action:^{
[weakConsumer focusNextTab];
}],
[UIKeyCommand [UIKeyCommand
cr_keyCommandWithInput:@"\t" cr_keyCommandWithInput:@"\t"
modifierFlags:UIKeyModifierControl | UIKeyModifierShift modifierFlags:UIKeyModifierControl | UIKeyModifierShift
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment