Search code examples
iostextviewnativescriptcaret

NativeScript - How to get the caret position of TextView in iOS


I'm using NativeScript-Vue and I'm having a problem finding out the caret position of TextView in iOS

<StackLayout>
    <TextView ref="input" editable=true @loaded="getView"/>
</StackLayout>

...

getView(args) {
    console.log(args.object.ios)      // return {}
    console.log(this.$refs.input.ios) // return {}
}

...

https://discourse.nativescript.org/t/getting-cursor-position-of-textview-in-ios/5931

I have read the solution above but it seems like only support TypeScript?

What I get from the this.$refs.input.nativeView.ios is always {} (empty)

Does anyone know what I missed? Or any available approach is welcome! Cheers


Solution

  • You have to use this.$refs.input.nativeView.ios only, it may print empty object as it's a native component.