mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
fix: 自定义工具的快捷键显示
This commit is contained in:
parent
3be0fe50ff
commit
5b74a22494
@ -55,9 +55,32 @@ function DefaultTool(props: CustomToolbarProps) {
|
||||
|
||||
function KeyTool(props: CustomToolbarProps<'hotkey'>) {
|
||||
const { item, toolbar } = props;
|
||||
|
||||
const unwarpAssist = (assist: number) => {
|
||||
let res = '';
|
||||
if (assist & (1 << 0)) {
|
||||
res += 'Ctrl + ';
|
||||
}
|
||||
if (assist & (1 << 1)) {
|
||||
res += 'Shift + ';
|
||||
}
|
||||
if (assist & (1 << 2)) {
|
||||
res += 'Alt + ';
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
const getKeyShow = (key: KeyCode, assist: number) => {
|
||||
return unwarpAssist(assist) + KeyCodeUtils.toString(key);
|
||||
};
|
||||
|
||||
return (
|
||||
<span class="button-text" onClick={() => toolbar.emitTool(item.id)}>
|
||||
{KeyCodeUtils.toString(item.key)}
|
||||
<span
|
||||
class="button-text"
|
||||
style="padding: 0 5px"
|
||||
onClick={() => toolbar.emitTool(item.id)}
|
||||
>
|
||||
{getKeyShow(item.key, item.assist)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user