cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dakridge
Advocate II
Advocate II

Setfocus on a newly visible item

In my app I have an Input Box that once the user clicks, opens a Search Box that the user can search a name and then choose and repopulate the Input Box.  I set the OnSelect state of the Input Box with a variable that will trigger the visible state of the Search Box.  I then put under the set command a SetFocus to move it to the newly visible Search Box. 

 

When the user clicks the Input Box makes the Search Box visible, but you have to click the Input Box again to make it move focus.  Not sure why it will not do both commands in the OnSelect of the Input Box. 

David K Akridge
Chief Information Officer, Mobile County Public Schools
1 ACCEPTED SOLUTION

Accepted Solutions
PowerAddict
Super User
Super User

Hi @dakridge

 

I would like to first say thank you to you for finding this weird behavior. I can confirm the following behavior: 

  1. If selecting the 1st text box makes the 2nd text box visible AND also tries to set focus on the 2nd text box, the set focus part doesn't work
  2. However, if we click again, then the set focus works fine
  3. Also, if the 2nd text box is visible from the beginning, then set focus works the 1st time itself

 

While I cannot say why this happens, if this is preventing you from achieving the desired behavior, I do have a workaround.

  • Add a label on top of the 2nd text box.
  • Set the visible property of the 2nd text box to true
  • Set the OnSelect of the 1st text box to 
Set(showVar, false)
  • Set the visible property of the label to 
!showVar
  • Ensure showVar is set to false when you come to the screen so the label is visible and covers the 2nd text box
  • Set the OnSelect of text box 1 to 
Set(showVar, true); SetFocus(TextBox2)​

Here is the behavior in both scenarios:

TextBox.gif

Let me know if this helps. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

 

View solution in original post

2 REPLIES 2
PowerAddict
Super User
Super User

Hi @dakridge

 

I would like to first say thank you to you for finding this weird behavior. I can confirm the following behavior: 

  1. If selecting the 1st text box makes the 2nd text box visible AND also tries to set focus on the 2nd text box, the set focus part doesn't work
  2. However, if we click again, then the set focus works fine
  3. Also, if the 2nd text box is visible from the beginning, then set focus works the 1st time itself

 

While I cannot say why this happens, if this is preventing you from achieving the desired behavior, I do have a workaround.

  • Add a label on top of the 2nd text box.
  • Set the visible property of the 2nd text box to true
  • Set the OnSelect of the 1st text box to 
Set(showVar, false)
  • Set the visible property of the label to 
!showVar
  • Ensure showVar is set to false when you come to the screen so the label is visible and covers the 2nd text box
  • Set the OnSelect of text box 1 to 
Set(showVar, true); SetFocus(TextBox2)​

Here is the behavior in both scenarios:

TextBox.gif

Let me know if this helps. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

 

Leave it to me to be trying to do something strange.  Thank you for confirming and for the work around.  

David K Akridge
Chief Information Officer, Mobile County Public Schools

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,759)