Commit fbb51781 authored by rockyl's avatar rockyl

有内容的节点内容变化后也要调整节点

parent d48d3204
...@@ -202,7 +202,6 @@ export class TextField extends Sprite { ...@@ -202,7 +202,6 @@ export class TextField extends Sprite {
this._lineSpacing = value; this._lineSpacing = value;
this.dirty = true; this.dirty = true;
} }
;
} }
public get lineSpacing(): number { public get lineSpacing(): number {
...@@ -255,7 +254,7 @@ export class TextField extends Sprite { ...@@ -255,7 +254,7 @@ export class TextField extends Sprite {
this.dirty = true; this.dirty = true;
} }
private _text: string = ""; protected _text: string = "";
/** /**
* 文本的css字体样式 * 文本的css字体样式
...@@ -321,7 +320,7 @@ export class TextField extends Sprite { ...@@ -321,7 +320,7 @@ export class TextField extends Sprite {
return this._fillColor; return this._fillColor;
} }
private _fillColor: any = "#ffffff"; private _fillColor: any = "#000";
/** /**
* 文本的描边颜色值 * 文本的描边颜色值
......
...@@ -63,11 +63,13 @@ class AdjustProxy { ...@@ -63,11 +63,13 @@ class AdjustProxy {
onAddedToStage(e) { onAddedToStage(e) {
this._host.parent.addEventListener(Event.RESIZE, this.onResize, this); this._host.parent.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this); this._host.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this);
} }
onRemovedFromStage(e) { onRemovedFromStage(e) {
this._host.parent.removeEventListener(Event.RESIZE, this.onResize); this._host.parent.removeEventListener(Event.RESIZE, this.onResize);
this._host.removeEventListener(Event.RESIZE, this.onResize, this);
this._host.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame); this._host.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
} }
......
...@@ -6,6 +6,7 @@ import Texture from "../../../2d/texture/Texture"; ...@@ -6,6 +6,7 @@ import Texture from "../../../2d/texture/Texture";
import {getAssetByName, getAssetByUUID} from "../assets-manager"; import {getAssetByName, getAssetByUUID} from "../assets-manager";
import {dataCenter} from "../data-center"; import {dataCenter} from "../data-center";
import {ESCAPE_REG_EXP} from "../../utils"; import {ESCAPE_REG_EXP} from "../../utils";
import {Event} from "../../../2d/events";
const assetScheme = 'asset://'; const assetScheme = 'asset://';
...@@ -49,23 +50,27 @@ export class Image extends Sprite { ...@@ -49,23 +50,27 @@ export class Image extends Sprite {
} }
private _setSource(value){ private _setSource(value){
let matchResult = value.match(ESCAPE_REG_EXP); if(value !== this._source){
let matchResult = value.match(ESCAPE_REG_EXP);
if (matchResult) { if (matchResult) {
this.unregisterEvents(); this.unregisterEvents();
this._originText = value; this._originText = value;
this._escapes.splice(0); this._escapes.splice(0);
for (let item of matchResult) { for (let item of matchResult) {
let escape = item.substr(2, item.length - 3); let escape = item.substr(2, item.length - 3);
let args = escape.split('|'); let args = escape.split('|');
let eventName = args[0]; let eventName = args[0];
this._escapes.push(escape); this._escapes.push(escape);
dataCenter.addEventListener(eventName, this.onDataMutated, this); dataCenter.addEventListener(eventName, this.onDataMutated, this);
this._registeredEvents.push(eventName); this._registeredEvents.push(eventName);
}
this.onDataMutated();
} else {
this._setSourceDirect(value);
} }
this.onDataMutated();
} else { this.dispatchEvent(Event.RESIZE);
this._setSourceDirect(value);
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import {TextField} from "../../../2d/text"; import {TextField} from "../../../2d/text";
import {dataCenter} from "../data-center"; import {dataCenter} from "../data-center";
import {ESCAPE_REG_EXP} from "../../utils"; import {ESCAPE_REG_EXP} from "../../utils";
import {Event} from "../../../2d/events";
/** /**
* 文本 * 文本
...@@ -19,23 +20,27 @@ export class Label extends TextField { ...@@ -19,23 +20,27 @@ export class Label extends TextField {
* @private * @private
*/ */
protected _setText(value) { protected _setText(value) {
let matchResult = value.match(ESCAPE_REG_EXP); if(value !== this._text){
let matchResult = value.match(ESCAPE_REG_EXP);
if (matchResult) { if (matchResult) {
this.unregisterEvents(); this.unregisterEvents();
this._originText = value; this._originText = value;
this._escapes.splice(0); this._escapes.splice(0);
for (let item of matchResult) { for (let item of matchResult) {
let escape = item.substr(2, item.length - 3); let escape = item.substr(2, item.length - 3);
let args = escape.split('|'); let args = escape.split('|');
let eventName = args[0]; let eventName = args[0];
this._escapes.push(escape); this._escapes.push(escape);
dataCenter.addEventListener(eventName, this.onDataMutated, this); dataCenter.addEventListener(eventName, this.onDataMutated, this);
this._registeredEvents.push(eventName); this._registeredEvents.push(eventName);
}
this.onDataMutated();
} else {
super._setText(value);
} }
this.onDataMutated();
} else { this.dispatchEvent(Event.RESIZE);
super._setText(value);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment