How to set focus to the next field?


#1

Sorry for a newbie question, I’m very new to NativeScript. I’m trying to switch a focus to the next element, but without success.

<TextField @returnPress="focusDescription()"
<TextField id="description" .../>

...

methods: {
    focusDescription: function () {
        page.getViewById("description").focus()
    }
},

#2

If you just set the return key type to next, it will focus next field upon hitting return.

Between, if you like to access elements from JS then use the Vue Ref that will be easier.


#3

When I press “Next” on a keyboard it disappeares and focus is not switched to the next field.

<TextField
    keyboardType="number"
    returnKeyType="next"/>
<TextField
    returnKeyType="done"/>

#4

I guess you are testing with iOS, I was talking about Android in my previous comment. For iOS you may install the iqkeyboardmanager plugin which will give next and previous buttons above the keyboard.

If you still prefer to take the control on your own, then you can access the elements as you will do in web,