mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
feat(text-field): add closeOnReturn property to avoid auto dismissing… (#8347)
* feat(text-field): add closeOnReturn property to avoid auto dismissing input on return press * tslint * Update NS public api Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com> Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com>
This commit is contained in:
@ -7,9 +7,13 @@ export * from "../editable-text-base";
|
||||
export class TextFieldBase extends EditableTextBase implements TextFieldDefinition {
|
||||
public static returnPressEvent = "returnPress";
|
||||
public secure: boolean;
|
||||
public closeOnReturn: boolean;
|
||||
}
|
||||
|
||||
TextFieldBase.prototype.recycleNativeView = "auto";
|
||||
|
||||
export const secureProperty = new Property<TextFieldBase, boolean>({ name: "secure", defaultValue: false, valueConverter: booleanConverter });
|
||||
secureProperty.register(TextFieldBase);
|
||||
|
||||
export const closeOnReturnProperty = new Property<TextFieldBase, boolean>({ name: "closeOnReturn", defaultValue: true, valueConverter: booleanConverter });
|
||||
closeOnReturnProperty.register(TextFieldBase);
|
||||
|
@ -27,4 +27,9 @@ export class TextField extends EditableTextBase {
|
||||
* Gets or sets if a text field is for password entry.
|
||||
*/
|
||||
secure: boolean;
|
||||
|
||||
/**
|
||||
* Gets or sets if a text field should dismiss on return.
|
||||
*/
|
||||
closeOnReturn: boolean;
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
||||
// Called when the user presses the return button.
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
owner.dismissSoftInput();
|
||||
if (owner.closeOnReturn) {
|
||||
owner.dismissSoftInput();
|
||||
}
|
||||
owner.notify({ eventName: TextField.returnPressEvent, object: owner });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user