mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Add accelerator shortcut in the tooltip for searching events panel
This commit is contained in:
@@ -6,6 +6,7 @@ import ToolbarIcon from '../UI/ToolbarIcon';
|
||||
import IconMenu from '../UI/Menu/IconMenu';
|
||||
import { mapFor } from '../Utils/MapFor';
|
||||
import flatten from 'lodash/flatten';
|
||||
import { adaptAcceleratorString } from '../UI/AcceleratorString';
|
||||
const gd = global.gd;
|
||||
|
||||
export class Toolbar extends PureComponent {
|
||||
@@ -122,7 +123,7 @@ export class Toolbar extends PureComponent {
|
||||
<ToolbarIcon
|
||||
onClick={() => this.props.onToggleSearchPanel()}
|
||||
src="res/ribbon_default/search32.png"
|
||||
tooltip={t('Search in events')}
|
||||
tooltip={`${t('Search in events')} ${adaptAcceleratorString('CmdOrCtrl+F')}`}
|
||||
/>
|
||||
{this.props.onOpenSettings && <ToolbarSeparator />}
|
||||
{this.props.onOpenSettings && (
|
||||
|
25
newIDE/app/src/UI/AcceleratorString.js
Normal file
25
newIDE/app/src/UI/AcceleratorString.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// @flow
|
||||
import { isMacLike, isMobile } from '../Utils/Platform';
|
||||
|
||||
export const adaptAcceleratorString = (accelerator: string): string => {
|
||||
if (isMobile()) {
|
||||
return ''; // Do not display accelerators on mobile devices
|
||||
} else if (isMacLike()) {
|
||||
return accelerator
|
||||
.replace(/CmdOrCtrl\+/, '⌘')
|
||||
.replace(/CommandOrControl\+/, '⌘')
|
||||
.replace(/Super\+/, '⌘')
|
||||
.replace(/Shift\+/, '⇧')
|
||||
.replace(/Alt\+/, '⌥')
|
||||
.replace(/Option\+/, '⌥')
|
||||
.replace(/Delete/, '⌦')
|
||||
.replace(/Backspace/, '⌫');
|
||||
} else {
|
||||
return accelerator
|
||||
.replace(/CmdOrCtrl\+/, 'Ctrl+')
|
||||
.replace(/CommandOrControl\+/, 'Ctrl+')
|
||||
.replace(/Super\+/, 'Win+')
|
||||
.replace(/Option\+/, 'Alt+')
|
||||
.replace(/Delete/, 'DEL');
|
||||
}
|
||||
};
|
@@ -1,30 +1,7 @@
|
||||
import React from 'react';
|
||||
import MenuItem from 'material-ui/MenuItem';
|
||||
import Divider from 'material-ui/Divider';
|
||||
import { isMacLike, isMobile } from '../../Utils/Platform';
|
||||
|
||||
const adaptAcceleratorString = (accelerator: string): string => {
|
||||
if (isMobile()) {
|
||||
return ''; // Do not display accelerators on mobile devices
|
||||
} else if (isMacLike()) {
|
||||
return accelerator
|
||||
.replace(/CmdOrCtrl\+/, '⌘')
|
||||
.replace(/CommandOrControl\+/, '⌘')
|
||||
.replace(/Super\+/, '⌘')
|
||||
.replace(/Shift\+/, '⇧')
|
||||
.replace(/Alt\+/, '⌥')
|
||||
.replace(/Option\+/, '⌥')
|
||||
.replace(/Delete/, '⌦')
|
||||
.replace(/Backspace/, '⌫');
|
||||
} else {
|
||||
return accelerator
|
||||
.replace(/CmdOrCtrl\+/, 'Ctrl+')
|
||||
.replace(/CommandOrControl\+/, 'Ctrl+')
|
||||
.replace(/Super\+/, 'Win+')
|
||||
.replace(/Option\+/, 'Alt+')
|
||||
.replace(/Delete/, 'DEL');
|
||||
}
|
||||
};
|
||||
import { adaptAcceleratorString } from '../AcceleratorString';
|
||||
|
||||
/**
|
||||
* Construct items for material-ui's Menu, using a template which
|
||||
|
Reference in New Issue
Block a user