fix editbox fringe (#4571)

This commit is contained in:
JoneLau
2019-06-10 12:59:27 +08:00
committed by Weiliang Wang
parent e65f9caebe
commit 06ace5842d
2 changed files with 19 additions and 14 deletions
@@ -28,8 +28,9 @@ import { SpriteFrame } from '../../../../assets/sprite-frame';
import { Component } from '../../../../components/component';
import { EventHandler as ComponentEventHandler } from '../../../../components/component-event-handler';
import { ccclass, executeInEditMode, executionOrder, menu, property } from '../../../../core/data/class-decorator';
import { EventTouch } from '../../../../core/platform';
import { SystemEventType } from '../../../../core/platform/event-manager/event-enum';
import Color from '../../../../core/value-types/color';
import { Color, Size } from '../../../../core/value-types';
import { Node } from '../../../../scene-graph';
import { LabelComponent, VerticalTextAlignment } from '../label-component';
import { SpriteComponent } from '../sprite-component';
@@ -561,7 +562,7 @@ export class EditBoxComponent extends Component {
}
}
public _updateLabelPosition (size) {
public _updateLabelPosition (size: Size) {
const node = this.node;
const offx = -node.anchorX * node.width;
const offy = -node.anchorY * node.height;
@@ -698,7 +699,7 @@ export class EditBoxComponent extends Component {
}
}
public _updateString (text) {
public _updateString (text: string) {
const textLabel = this._textLabel;
// Not inited yet
if (!textLabel) {
@@ -765,21 +766,21 @@ export class EditBoxComponent extends Component {
this.node.emit('editing-return', this);
}
public _onTouchBegan (event) {
public _onTouchBegan (event: EventTouch) {
if (this._impl) {
this._impl._onTouchBegan(event.touch);
}
event.propagationStopped = true;
}
public _onTouchCancel (event) {
// if (this._impl) {
// this._impl._onTouchCancel();
// }
event.propagationStopped = true;
}
// public _onTouchCancel (event) {
// // if (this._impl) {
// // this._impl._onTouchCancel();
// // }
// event.propagationStopped = true;
// }
public _onTouchEnded (event) {
public _onTouchEnded (event: EventTouch) {
if (this._impl) {
this._impl._onTouchEnded();
}
@@ -123,6 +123,10 @@ export class EditBoxImpl {
return this._alwaysOnTop;
}
get editing (){
return this._editing;
}
set editing (value: boolean) {
this._editing = value;
}
@@ -153,7 +157,7 @@ export class EditBoxImpl {
this._edTxt.style.display = 'none';
}
public setTabIndex (index) {
public setTabIndex (index: number) {
if (this._edTxt) {
this._edTxt.tabIndex = index;
}
@@ -183,7 +187,7 @@ export class EditBoxImpl {
}
}
public setMaxLength (maxLength) {
public setMaxLength (maxLength: number) {
if (!isNaN(maxLength)) {
if (maxLength < 0) {
// we can't set Number.MAX_VALUE to input's maxLength property
@@ -197,7 +201,7 @@ export class EditBoxImpl {
}
}
public setString (text) {
public setString (text: string) {
this._text = text;
if (this._edTxt) {
this._edTxt.value = text;