Commit fbb51781 authored by rockyl's avatar rockyl

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

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