Skip to content

Commit

Permalink
don't force top align editbox placeholder label (cocos#11303)
Browse files Browse the repository at this point in the history
* dont force top align editbox placeholder label

* no need to update placeholder style

* optimize code
  • Loading branch information
PPpro authored Jun 10, 2022
1 parent 78dfe5b commit ea38500
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cocos/ui/editbox/edit-box-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,11 @@ export class EditBoxImpl extends EditBoxImplBase {
const elem = this._edTxt;
if (elem && delegate) {
elem.value = delegate.string;
elem.placeholder = delegate.placeholder;

this._updateTextLabel(delegate.textLabel);
this._updatePlaceholderLabel(delegate.placeholderLabel);

// NOTE: we don't show placeholder any more when editBox is editing
// elem.placeholder = delegate.placeholder;
// this._updatePlaceholderLabel(delegate.placeholderLabel);
}
}

Expand Down
4 changes: 0 additions & 4 deletions cocos/ui/editbox/edit-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ export class EditBox extends Component {
const transform = this._placeholderLabel!.node._uiProps.uiTransformComp;
transform!.setAnchorPoint(0, 1);
if (this._inputMode === InputMode.ANY) {
placeholderLabel.verticalAlign = VerticalTextAlignment.TOP;
placeholderLabel.enableWrapText = true;
} else {
placeholderLabel.enableWrapText = false;
Expand Down Expand Up @@ -737,9 +736,6 @@ export class EditBox extends Component {
placeholderLabel.node._uiProps.uiTransformComp!.setContentSize(size.width - LEFT_PADDING, size.height);
placeholderLabel.lineHeight = size.height;
placeholderLabel.node.setPosition(offX + LEFT_PADDING, offY + size.height, placeholderLabel.node.position.z);
if (this._inputMode === InputMode.ANY) {
placeholderLabel.verticalAlign = VerticalTextAlignment.TOP;
}
placeholderLabel.enableWrapText = this._inputMode === InputMode.ANY;
}
}
Expand Down

0 comments on commit ea38500

Please sign in to comment.