Reputation: 49
When user click ouside of TextField , I want to remove focus from textfield. How to do this in nativescript ?
Upvotes: 0
Views: 2386
Reputation: 21908
Here is how you could remove focus from your TextField on Android. You need another view where the focus can be shifted. The sample was done with {N} core, implementing in {N} Vue follows the standard steps, register the custom element and use it on your template.
To hide keyboard, execute the code below upon tapping your layout (anywhere outside the TextField).
import * as utils from "tns-core-modules/utils/utils";
if (utils.ad) {
utils.ad.dismissSoftInput();
} else {
// iOS
utils.ios
.getter(UIApplication, UIApplication.sharedApplication)
.keyWindow
.endEditing(true);
}
Upvotes: 1