mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #1796 from NativeScript/nsrange-exception
Fix NSRangeException when typing in a TextField with formatted text
This commit is contained in:
@ -82,11 +82,13 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
|||||||
owner._onPropertyChangedFromNative(TextBase.textProperty, replacementString);
|
owner._onPropertyChangedFromNative(TextBase.textProperty, replacementString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (range.location <= textField.text.length) {
|
||||||
let newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
|
let newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
|
||||||
owner._onPropertyChangedFromNative(TextBase.textProperty, newText);
|
owner._onPropertyChangedFromNative(TextBase.textProperty, newText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.firstEdit = false;
|
this.firstEdit = false;
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user