Commit cb3a7c50 authored by Jan Scheffler's avatar Jan Scheffler Committed by Commit Bot

[devtools] Show shortcut in button tooltip again

Fixed regression introduced in #1693175 (https://chromium-review.googlesource.com/c/chromium/src/+/1693175/4/third_party/blink/renderer/devtools/front_end/ui/Toolbar.js) which kept
toolbar buttons from showing their keyboard shortcuts
in the tooltip.

Bug: chromium:999195
Change-Id: I0d0259f19a4abc45d3fe57df419319866e311688
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1782172
Commit-Queue: Jan Scheffler <janscheffler@google.com>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693823}
parent c24d99c8
...@@ -163,7 +163,8 @@ UI.Toolbar = class { ...@@ -163,7 +163,8 @@ UI.Toolbar = class {
* @return {!UI.ToolbarButton} * @return {!UI.ToolbarButton}
*/ */
static createActionButton(action, showLabel) { static createActionButton(action, showLabel) {
const button = makeButtonOrToggle(); const button = action.toggleable() ? makeToggle() : makeButton();
if (showLabel) if (showLabel)
button.setText(action.title()); button.setText(action.title());
button.addEventListener(UI.ToolbarButton.Events.Click, action.execute, action); button.addEventListener(UI.ToolbarButton.Events.Click, action.execute, action);
...@@ -174,9 +175,18 @@ UI.Toolbar = class { ...@@ -174,9 +175,18 @@ UI.Toolbar = class {
/** /**
* @return {!UI.ToolbarButton} * @return {!UI.ToolbarButton}
*/ */
function makeButtonOrToggle() {
if (!action.toggleable()) function makeButton() {
return new UI.ToolbarButton(action.title(), action.icon()); const button = new UI.ToolbarButton(action.title(), action.icon());
if (action.title())
UI.Tooltip.install(button.element, action.title(), action.id());
return button;
}
/**
* @return {!UI.ToolbarToggle}
*/
function makeToggle() {
const toggleButton = new UI.ToolbarToggle(action.title(), action.icon(), action.toggledIcon()); const toggleButton = new UI.ToolbarToggle(action.title(), action.icon(), action.toggledIcon());
toggleButton.setToggleWithRedColor(action.toggleWithRedColor()); toggleButton.setToggleWithRedColor(action.toggleWithRedColor());
action.addEventListener(UI.Action.Events.Toggled, toggled); action.addEventListener(UI.Action.Events.Toggled, toggled);
......
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