mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Merge pull request #383 from NativeScript/nnikolov/Issue368
Fixed issue 368.
This commit is contained in:
@ -23,13 +23,15 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _owner: TextField;
|
private _owner: TextField;
|
||||||
|
private firstEdit: boolean;
|
||||||
|
|
||||||
public initWithOwner(owner: TextField): UITextFieldDelegateImpl {
|
public initWithOwner(owner: TextField): UITextFieldDelegateImpl {
|
||||||
this._owner = owner;
|
this._owner = owner;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public textFieldShouldBeginEditing(textField: UITextField): boolean {
|
public textFieldShouldBeginEditing(textField: UITextField): boolean {
|
||||||
|
this.firstEdit = true;
|
||||||
return this._owner.editable;
|
return this._owner.editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +43,12 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
|||||||
this._owner.dismissSoftInput();
|
this._owner.dismissSoftInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public textFieldShouldClear(textField: UITextField) {
|
||||||
|
this.firstEdit = false;
|
||||||
|
this._owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public textFieldShouldReturn(textField: UITextField): boolean {
|
public textFieldShouldReturn(textField: UITextField): boolean {
|
||||||
// Called when the user presses the return button.
|
// Called when the user presses the return button.
|
||||||
this._owner.dismissSoftInput();
|
this._owner.dismissSoftInput();
|
||||||
@ -49,9 +57,15 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
|||||||
|
|
||||||
public textFieldShouldChangeCharactersInRangeReplacementString(textField: UITextField, range: NSRange, replacementString: string): boolean {
|
public textFieldShouldChangeCharactersInRangeReplacementString(textField: UITextField, range: NSRange, replacementString: string): boolean {
|
||||||
if (this._owner.updateTextTrigger === enums.UpdateTextTrigger.textChanged) {
|
if (this._owner.updateTextTrigger === enums.UpdateTextTrigger.textChanged) {
|
||||||
var newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
|
if (textField.secureTextEntry && this.firstEdit) {
|
||||||
this._owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, newText);
|
this._owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, replacementString);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
|
||||||
|
this._owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, newText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.firstEdit = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user