mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 20:59:37 +08:00
feat: CustomTool链式调用
This commit is contained in:
parent
72d74ec7a6
commit
334c25fb7a
@ -102,6 +102,7 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
} as ToolbarItemMap[K];
|
} as ToolbarItemMap[K];
|
||||||
this.items.push(data);
|
this.items.push(data);
|
||||||
this.emit('add', data);
|
this.emit('add', data);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,6 +115,7 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
const item = this.items[index];
|
const item = this.items[index];
|
||||||
this.items.splice(index, 1);
|
this.items.splice(index, 1);
|
||||||
this.emit('delete', item);
|
this.emit('delete', item);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,6 +131,7 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
if (!toSet) return;
|
if (!toSet) return;
|
||||||
Object.assign(toSet, item);
|
Object.assign(toSet, item);
|
||||||
this.emit('set', id, item);
|
this.emit('set', id, item);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,7 +175,7 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
this.items.push(...items);
|
this.items.push(...items);
|
||||||
});
|
});
|
||||||
// this.items.push(...this.items.splice(0));
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPos(x?: number, y?: number) {
|
setPos(x?: number, y?: number) {
|
||||||
@ -196,18 +199,19 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
|
|
||||||
hook.once('reset', () => {
|
hook.once('reset', () => {
|
||||||
const toolbar = new CustomToolbar('test');
|
const toolbar = new CustomToolbar('test');
|
||||||
toolbar.add<'hotkey'>({
|
toolbar
|
||||||
|
.add<'hotkey'>({
|
||||||
id: 'test1',
|
id: 'test1',
|
||||||
type: 'hotkey',
|
type: 'hotkey',
|
||||||
assist: 0,
|
assist: 0,
|
||||||
key: KeyCode.KeyX
|
key: KeyCode.KeyX
|
||||||
});
|
})
|
||||||
toolbar.add<'assistKey'>({
|
.add<'assistKey'>({
|
||||||
id: 'test2',
|
id: 'test2',
|
||||||
type: 'assistKey',
|
type: 'assistKey',
|
||||||
assist: KeyCode.Ctrl
|
assist: KeyCode.Ctrl
|
||||||
});
|
})
|
||||||
toolbar.add<'item'>({
|
.add<'item'>({
|
||||||
id: 'test3',
|
id: 'test3',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
item: 'book'
|
item: 'book'
|
||||||
|
Loading…
Reference in New Issue
Block a user