mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
#3614 Feature request: TextField maxLength
property support.
- Implemented @PanayotCankov's Android 'view recycle' remark.
This commit is contained in:

committed by
vakrilov

parent
da6562b506
commit
eda57d2c35
@ -431,6 +431,21 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
[maxLengthProperty.setNative](value: number) {
|
||||
this.nativeView.setFilters([new android.text.InputFilter.LengthFilter(+value)]);
|
||||
let lengthFilter = new android.text.InputFilter.LengthFilter(+value);
|
||||
let filters = this.nativeView.getFilters();
|
||||
let newFilters = [];
|
||||
|
||||
// retain existing filters
|
||||
for (let i = 0; i < filters.length; i++) {
|
||||
newFilters.push(filters[i]);
|
||||
// update an existing length filter
|
||||
if (filters[i] instanceof android.text.InputFilter.LengthFilter) {
|
||||
filters[i] = lengthFilter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// no current length filter found, so add it
|
||||
newFilters.push(lengthFilter);
|
||||
this.nativeView.setFilters(newFilters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user