Skip to content

Commit

Permalink
Fix key shortcut display issues
Browse files Browse the repository at this point in the history
(closes #1272)

This update includes several changes:
- Rename `tooltip.keys()` to `tooltip.shortcut()`
  `keys` is too overloaded/common of a word in JavaScript
- Also make it just work with a string, not a single element array with a string in it
- Change tooltip key hint text from "Shortcut:" to just say "Key:" it's shorter and
  easier for users to read, also make the key hint only appear for single key shortcut
  • Loading branch information
bhousel committed Jan 2, 2024
1 parent 6473615 commit 13d08e3
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 144 deletions.
17 changes: 8 additions & 9 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5249,17 +5249,16 @@ button.conflicts-button {
}

.tooltip-keyhint {
padding: 10px;
margin: 10px -10px -10px -10px;
padding: 10px;
margin: 10px -10px -10px -10px;
}
.popover-inner .shortcut {
font-weight: bold;
margin-left: 5px;
.tooltip-keyhint .tooltip-keys {
padding: 0 3px;
white-space: nowrap;
}

.ideditor[dir='rtl'] .popover-inner .shortcut {
margin-left: 0;
margin-right: 5px;
.tooltip-keys kbd.shortcut {
font-size: 10px;
font-weight: bold;
}

/* dark tooltips for sidebar / panels */
Expand Down
2 changes: 1 addition & 1 deletion data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ en:
title: Redo
tooltip: "Redo: {action}"
nothing: Nothing to redo.
tooltip_keyhint: "Shortcut:"
tooltip_keyhint: "Key:"
translate:
translate: Add multilingual name
localized_translation_label: Multilingual Name
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/edit_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function uiEditMenu(context) {
let tooltip = uiTooltip(context)
.heading(d.title)
.title(d.tooltip())
.keys([d.keys[0]]); // display the first key combo, if there are alternates
.shortcut(d.keys[0]); // display the first key combo, if there are alternates

_tooltips.push(tooltip);

Expand Down
2 changes: 1 addition & 1 deletion modules/ui/pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function uiPane(context, id) {
_paneTooltip = uiTooltip(context)
.placement(isRTL ? 'right' : 'left')
.title(_description)
.keys([_key]);
.shortcut(_key);
}

selection
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/panes/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export function uiPaneHelp(context) {
.attr('class', 'shortcuts')
.call(uiTooltip(context)
.title(l10n.t('shortcuts.tooltip'))
.keys(['?'])
.shortcut('?')
.placement('top')
)
.append('a')
Expand Down
12 changes: 6 additions & 6 deletions modules/ui/rapid_feature_inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,23 @@ export function uiRapidFeatureInspector(context, keybinding) {
.on('click', onClick);

// build tooltips
let title, keys;
let title, shortcut;
if (d.key === 'accept') {
if (isAddFeatureDisabled()) {
title = l10n.t('rapid_feature_inspector.option_accept.disabled', { n: ACCEPT_FEATURES_LIMIT } );
keys = [];
shortcut = '';
} else {
title = l10n.t('rapid_feature_inspector.option_accept.tooltip');
keys = [l10n.t('rapid_feature_inspector.option_accept.key')];
shortcut = l10n.t('rapid_feature_inspector.option_accept.key');
}
} else if (d.key === 'ignore') {
title = l10n.t('rapid_feature_inspector.option_ignore.tooltip');
keys = [l10n.t('rapid_feature_inspector.option_ignore.key')];
shortcut = l10n.t('rapid_feature_inspector.option_ignore.key');
}

if (title && keys) {
if (title) {
choiceButton = choiceButton
.call(uiTooltip(context).placement('bottom').title(title).keys(keys));
.call(uiTooltip(context).placement('bottom').title(title).shortcut(shortcut));
}

choiceButton
Expand Down
10 changes: 5 additions & 5 deletions modules/ui/sections/background_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function uiSectionBackgroundList(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('background.minimap.tooltip'))
.keys([l10n.t('background.minimap.key')])
.shortcut(l10n.t('background.minimap.key'))
.placement('top')
);

Expand All @@ -90,7 +90,7 @@ export function uiSectionBackgroundList(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('background.3dmap.tooltip'))
.keys([uiCmd('⌘' + l10n.t('background.3dmap.key'))])
.shortcut(uiCmd('⌘' + l10n.t('background.3dmap.key')))
.placement('top')
);

Expand All @@ -113,7 +113,7 @@ export function uiSectionBackgroundList(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('background.panel.tooltip'))
.keys([uiCmd('⌘⇧' + l10n.t('info_panels.background.key'))])
.shortcut(uiCmd('⌘⇧' + l10n.t('info_panels.background.key')))
.placement('top')
);

Expand All @@ -135,7 +135,7 @@ export function uiSectionBackgroundList(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('background.location_panel.tooltip'))
.keys([uiCmd('⌘⇧' + l10n.t('info_panels.location.key'))])
.shortcut(uiCmd('⌘⇧' + l10n.t('info_panels.location.key')))
.placement('top')
);

Expand Down Expand Up @@ -183,7 +183,7 @@ export function uiSectionBackgroundList(context) {
item.call(uiTooltip(context)
.placement(placement)
.title(l10n.t('background.switch'))
.keys([uiCmd('⌘' + l10n.t('background.key'))])
.shortcut(uiCmd('⌘' + l10n.t('background.key')))
);
} else if (d.description || isOverflowing) {
item.call(uiTooltip(context)
Expand Down
6 changes: 3 additions & 3 deletions modules/ui/sections/data_layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function uiSectionDataLayers(context) {
d3_select(nodes[i])
.call(uiTooltip(context)
.title(l10n.t(`map_data.layers.${d.id}.tooltip`))
.keys([uiCmd('⌥' + l10n.t('area_fill.wireframe.key'))])
.shortcut(uiCmd('⌥' + l10n.t('area_fill.wireframe.key')))
.placement('bottom')
);
} else {
Expand Down Expand Up @@ -286,7 +286,7 @@ export function uiSectionDataLayers(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('map_data.history_panel.tooltip'))
.keys([uiCmd('⌘⇧' + l10n.t('info_panels.history.key'))])
.shortcut(uiCmd('⌘⇧' + l10n.t('info_panels.history.key')))
.placement('top')
);

Expand All @@ -308,7 +308,7 @@ export function uiSectionDataLayers(context) {
.append('label')
.call(uiTooltip(context)
.title(l10n.t('map_data.measurement_panel.tooltip'))
.keys([uiCmd('⌘⇧' + l10n.t('info_panels.measurement.key'))])
.shortcut(uiCmd('⌘⇧' + l10n.t('info_panels.measurement.key')))
.placement('top')
);

Expand Down
10 changes: 4 additions & 6 deletions modules/ui/sections/map_style_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ export function uiSectionMapStyleOptions(context) {
.append('li')
.call(uiTooltip(context)
.title(d => l10n.t(`${name}.${d}.tooltip`))
.keys(d => {
let key = (d === 'wireframe' ? l10n.t('area_fill.wireframe.key') : null);
if (d === 'highlight_edits') {
key = l10n.t('map_data.highlight_edits.key');
}
return key ? [key] : null;
.shortcut(d => {
if (d === 'wireframe') return l10n.t('area_fill.wireframe.key');
if (d === 'highlight_edits') return l10n.t('map_data.highlight_edits.key');
return null;
})
.placement('top')
);
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/tools/modes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function uiToolDrawModes(context) {
.call(uiTooltip(context)
.placement('bottom')
.title(d => d.description)
.keys(d => [d.key])
.shortcut(d => d.key)
.scrollContainer(context.container().select('.top-toolbar'))
);

Expand Down
2 changes: 1 addition & 1 deletion modules/ui/tools/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function uiToolNotes(context) {
.call(uiTooltip(context)
.placement('bottom')
.title(d => d.description)
.keys(d => [d.key])
.shortcut(d => d.key)
.scrollContainer(context.container().select('.top-toolbar'))
);

Expand Down
2 changes: 1 addition & 1 deletion modules/ui/tools/rapid_features.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function uiToolRapidFeatures(context) {
.call(uiTooltip(context)
.placement('bottom')
.title(l10n.t('shortcuts.browsing.display_options.rapid_features_data'))
.keys(rapidFeaturesToggleKey)
.shortcut(rapidFeaturesToggleKey)
);

rapidButtonEnter
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/tools/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function uiToolSave(context) {
if (_tooltip) {
_tooltip
.title(l10n.t(_numChanges > 0 ? 'save.help' : 'save.no_changes'))
.keys([key]);
.shortcut(key);
}

_button
Expand Down Expand Up @@ -86,7 +86,7 @@ export function uiToolSave(context) {
_tooltip = uiTooltip(context)
.placement('bottom')
.title(l10n.t('save.no_changes'))
.keys([key])
.shortcut(key)
.scrollContainer(context.container().select('.top-toolbar'));

// var lastPointerUpType;
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/tools/sidebar_toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function uiToolSidebarToggle(context) {
.call(uiTooltip(context)
.placement('bottom')
.title(l10n.t('sidebar.tooltip'))
.keys([ l10n.t('sidebar.key') ])
.shortcut(l10n.t('sidebar.key'))
.scrollContainer(context.container().select('.top-toolbar'))
)
.call(uiIcon('#rapid-icon-sidebar-' + (l10n.isRTL() ? 'right' : 'left')));
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/tools/undo_redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function uiToolUndoRedo(context) {
}
return str ? l10n.t(`${d.id}.tooltip`, { action: str }) : l10n.t(`${d.id}.nothing`);
})
.keys(d => [d.key])
.shortcut(d => d.key)
.scrollContainer(context.container().select('.top-toolbar'));

// var lastPointerUpType;
Expand Down
Loading

0 comments on commit 13d08e3

Please sign in to comment.