From c7cf4f0c2d9a50965d94fc21fa6e4cbeb9e2280f Mon Sep 17 00:00:00 2001 From: JoneLau <32630749+JoneLau@users.noreply.github.com> Date: Wed, 8 Jan 2020 12:56:31 +0800 Subject: [PATCH] fix editbox eventtype and remove unless code (#6044) --- .../ui/components/editbox/edit-box-component.ts | 16 ++++++++++++---- cocos/ui/components/label-component.ts | 14 +------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/cocos/ui/components/editbox/edit-box-component.ts b/cocos/ui/components/editbox/edit-box-component.ts index 02576c5372..96db97997f 100644 --- a/cocos/ui/components/editbox/edit-box-component.ts +++ b/cocos/ui/components/editbox/edit-box-component.ts @@ -55,6 +55,13 @@ function capitalize (str: string) { function capitalizeFirstLetter (str: string) { return str.charAt(0).toUpperCase() + str.slice(1); } + +enum EventType { + EDITING_DID_BEGAN = 'editing-did-began', + EDITING_DID_ENDED = 'editing-did-ended', + TEXT_CHANGED = 'text-changed', + EDITING_RETURN = 'editing-return', +} /** * @en * cc.EditBoxComponent is a component for inputing text, you can use it to gather small amounts of text from users. @@ -429,6 +436,7 @@ export class EditBoxComponent extends Component { public static KeyboardReturnType = KeyboardReturnType; public static InputFlag = InputFlag; public static InputMode = InputMode; + public static EventType = EventType; /** * @en * The event handler to be called when EditBox began to edit text. @@ -585,24 +593,24 @@ export class EditBoxComponent extends Component { public _editBoxEditingDidBegan () { ComponentEventHandler.emitEvents(this.editingDidBegan, this); - this.node.emit('editing-did-began', this); + this.node.emit(EventType.EDITING_DID_BEGAN, this); } public _editBoxEditingDidEnded () { ComponentEventHandler.emitEvents(this.editingDidEnded, this); - this.node.emit('editing-did-ended', this); + this.node.emit(EventType.EDITING_DID_ENDED, this); } public _editBoxTextChanged (text: string) { text = this._updateLabelStringStyle(text, true); this.string = text; ComponentEventHandler.emitEvents(this.textChanged, text, this); - this.node.emit('text-changed', this); + this.node.emit(EventType.TEXT_CHANGED, this); } public _editBoxEditingReturn () { ComponentEventHandler.emitEvents(this.editingReturn, this); - this.node.emit('editing-return', this); + this.node.emit(EventType.EDITING_RETURN, this); } public _showLabels () { diff --git a/cocos/ui/components/label-component.ts b/cocos/ui/components/label-component.ts index 8697c62b2d..7df73ac104 100644 --- a/cocos/ui/components/label-component.ts +++ b/cocos/ui/components/label-component.ts @@ -732,19 +732,7 @@ export class LabelComponent extends UIRenderComponent { } protected _flushMaterial () { - const material = this._material; - // Setup blend function for premultiplied ttf label texture - // if (this._texture === this._ttfSpriteFrame) { - // this._srcBlendFactor = macro.BlendFactor.ONE; - // } else { - // this._srcBlendFactor = macro.BlendFactor.SRC_ALPHA; - // } - - if (material) { - material.setProperty('mainTexture', this._texture); - } - - this._updateMaterial(material); + this._updateMaterial(this._material); } protected _applyFontTexture (force: boolean) {