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 II
Super User II

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 II
Super User II

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

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (74,837)