cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marcelvos
Helper I
Helper I

SetFocus on first screen

Hi,

I try to focus the first field on a screen with SetFocus but it don't work. This probleem only exists for me on the first screen when I open the app. In all other cases SetFocus is working very well.

I used the SetFocus function in the Onvisible trigger of the screen.

 

Thanks.

 

Marcel Vos

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @marcelvos ,

Could you please share a bit more about the "field" you want to focus on?

Is the "field" existed within the Screen or within a Gallery?

 

Currently, there are some known limits with SetFocus() function. Please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-setfocus#limitations

 

The SetFocus function could only be applied to Button, Icon, Image, Label and TextInput control. And these controls could not be in a Gallery control, Edit form control, or Component.

 

Please make sure the "field" you want to set focus on is not existed within a Gallery control, Edit form control, or Component. You could add a scrollable screen in your app, the SetFocus can be used with a control in a scrollbale screen.

 

Please set the OnVisible property of the screen to following:

SetFocus(TextInputControl)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
EricLott
Resident Rockstar
Resident Rockstar

Try Select()

---
If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

Thanks.

We tested this but it gives the same issue. Focus on a field on startup of the app is not working. Are there some other tricks?

Is SetFocus() the last (or only) function in the OnVisible property?

Hi Eric,

 

It was the last function. Before SetFocus I used the set function. Now I moved the SetFocus before the Set function without any result.

Do you think that other functions gives problems with SetFocus? I'am no longer with the customer but tuesday I can test this with the customer's scanner.

 

I let you know the test results. Thank you in advance.

 

Greeting, Marcel

I'm not sure exactly. I did a test on my end and was able to focus on a text input using SetFocus() in the OnVisible property. There seems to be something interfering with yours but I'm not sure what it would be..

v-xida-msft
Community Support
Community Support

Hi @marcelvos ,

Could you please share a bit more about the "field" you want to focus on?

Is the "field" existed within the Screen or within a Gallery?

 

Currently, there are some known limits with SetFocus() function. Please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-setfocus#limitations

 

The SetFocus function could only be applied to Button, Icon, Image, Label and TextInput control. And these controls could not be in a Gallery control, Edit form control, or Component.

 

Please make sure the "field" you want to set focus on is not existed within a Gallery control, Edit form control, or Component. You could add a scrollable screen in your app, the SetFocus can be used with a control in a scrollbale screen.

 

Please set the OnVisible property of the screen to following:

SetFocus(TextInputControl)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi,

 

Thanks for your answer.

The field is a text field. I used a empty screen. See image for more details.

 

2020-01-17_08-47-19.png

yashag2255
Dual Super User II
Dual Super User II

Hi @marcelvos 

 

Can you try to Set focus on the "OnStart" property of the App? It will be triggered whenever the app is opened/refreshed.
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @marcelvos ,

 

Are you working on Apple iOS?

See, SetFocus explained :

"On Apple iOS, the soft keyboard will only be displayed automatically if SetFocus was initiated by a direct user action. For example, invoking from a button's OnSelect property will display the soft keyboard while invoking from a screen's OnVisible will not."

 

I just tested this, indeed it is working if SetFocus was initiated by a direct user action and not from a screen's OnVisible. Also, tested this on my mobile, then it is working from the screen's OnVisible.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,503)