feat(text-view): add returnPress (#9390)

closes #4882
This commit is contained in:
Osei Fortune
2021-05-12 11:22:20 -04:00
committed by GitHub
parent 0b2c190662
commit 64adf5ecfc
3 changed files with 9 additions and 0 deletions

View File

@ -28,6 +28,10 @@ export class TextView extends TextViewBaseCommon {
this.nativeTextViewProtected.setMaxLines(value); this.nativeTextViewProtected.setMaxLines(value);
} }
public _onReturnPress() {
this.notify({ eventName: TextView.returnPressEvent, object: this });
}
} }
TextView.prototype.recycleNativeView = 'auto'; TextView.prototype.recycleNativeView = 'auto';

View File

@ -167,6 +167,10 @@ export class TextView extends TextViewBaseCommon {
} }
} }
if (replacementString === '\n') {
this.notify({ eventName: TextView.returnPressEvent, object: this });
}
if (this.formattedText) { if (this.formattedText) {
_updateCharactersInRangeReplacementString(this.formattedText, range.location, range.length, replacementString); _updateCharactersInRangeReplacementString(this.formattedText, range.location, range.length, replacementString);
} }

View File

@ -3,6 +3,7 @@ import { EditableTextBase } from '../editable-text-base';
import { Property } from '../core/properties'; import { Property } from '../core/properties';
export class TextViewBase extends EditableTextBase implements TextViewDefinition { export class TextViewBase extends EditableTextBase implements TextViewDefinition {
public static returnPressEvent = 'returnPress';
public maxLines: number; public maxLines: number;
} }