mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
重命名物体事件。
This commit is contained in:
parent
84d659c5d1
commit
b43df85df0
@ -61,11 +61,8 @@ Editor.prototype = {
|
||||
this.app.call('moveObject', this, object, parent, before);
|
||||
},
|
||||
|
||||
nameObject: function (object, name) {
|
||||
|
||||
object.name = name;
|
||||
this.signals.sceneGraphChanged.dispatch();
|
||||
|
||||
nameObject: function (object, name) { // 重命名物体
|
||||
this.app.call('nameObject', this, object, name);
|
||||
},
|
||||
|
||||
removeObject: function (object) {
|
||||
|
||||
@ -15,6 +15,7 @@ import SetThemeEvent from './editor/SetThemeEvent';
|
||||
import SetSceneEvent from './editor/SetSceneEvent';
|
||||
import AddObjectEvent from './editor/AddObjectEvent';
|
||||
import MoveObjectEvent from './editor/MoveObjectEvent';
|
||||
import NameObjectEvent from './editor/NameObjectEvent';
|
||||
|
||||
/**
|
||||
* 事件执行器
|
||||
@ -40,6 +41,7 @@ function EventDispatcher(app) {
|
||||
new SetSceneEvent(this.app),
|
||||
new AddObjectEvent(this.app),
|
||||
new MoveObjectEvent(this.app),
|
||||
new NameObjectEvent(this.app),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,9 @@ var EventList = [
|
||||
// editor事件
|
||||
'setTheme', // 设置编辑器主题
|
||||
'setScene', // 设置编辑器场景
|
||||
'addObject', //向编辑器添加物体
|
||||
'moveObject', // 移动编辑器中的物体
|
||||
'addObject', // 添加物体
|
||||
'moveObject', // 移动物体
|
||||
'nameObject', // 重命名物体
|
||||
];
|
||||
|
||||
export default EventList;
|
||||
32
src/event/editor/NameObjectEvent.js
Normal file
32
src/event/editor/NameObjectEvent.js
Normal file
@ -0,0 +1,32 @@
|
||||
import BaseEvent from '../BaseEvent';
|
||||
|
||||
/**
|
||||
* 重命名物体事件
|
||||
* @param {*} app
|
||||
*/
|
||||
function NameObjectEvent(app) {
|
||||
BaseEvent.call(this, app);
|
||||
}
|
||||
|
||||
NameObjectEvent.prototype = Object.create(BaseEvent.prototype);
|
||||
NameObjectEvent.prototype.constructor = NameObjectEvent;
|
||||
|
||||
NameObjectEvent.prototype.start = function () {
|
||||
var _this = this;
|
||||
this.app.on('nameObject.' + this.id, function (object, name) {
|
||||
_this.onNameObject(object);
|
||||
});
|
||||
};
|
||||
|
||||
NameObjectEvent.prototype.stop = function () {
|
||||
this.app.on('nameObject.' + this.id, null);
|
||||
};
|
||||
|
||||
NameObjectEvent.prototype.onNameObject = function (object, name) {
|
||||
var editor = this.app.editor;
|
||||
|
||||
object.name = name;
|
||||
editor.signals.sceneGraphChanged.dispatch();
|
||||
};
|
||||
|
||||
export default NameObjectEvent;
|
||||
Loading…
x
Reference in New Issue
Block a user