Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

set focus on a other control not working?

(0) ShareShare
ReportReport
Posted on by 997

Hello,

I was wondering how i can set focus on a other control
Yes i know with

 

Setfocus(a control)

 

But seems not working
I set this on my TextInput control

 

Reset(Self);;Reset(Gallery2);;Set(var_Gallery2;false);;Reset(Timer_Search)

 

the timer on start and autostart
OnTimerStart

 

Set(var_Gallery2;false)

 

OnTimerEnd

 

Reset(Gallery2);;
Set(var_Gallery2;true);;
SetFocus(Button1)

OnAutoStart

If(CountRows(Gallery2.AllItems)>0;true;false)

 

But focus isn't working
I have my button and other controls
In screen2

TimmyBoy_0-1708806734435.png

So the Gallery is in a other container
Just like the Button1, the timer is on the screen 2

TimmyBoy_1-1708806805807.png

Any help please
Thank you

 

  • Pstork1 Profile Picture
    Pstork1 64,722 on at
    Re: set focus on a other control not working?

    Since setting the focus is all about input it makes sense that you can't set focus to a control that can't be seen or that is read only. Glad you solved the issue.

  • TimmyBoy Profile Picture
    TimmyBoy 997 on at
    Re: set focus on a other control not working?

    Hi @Pstork1 

    Guess it's my fault 🙄
    The button1 can't be hidden if you want to add the focus
    I added a new button at the same location of the timer as you provided
    And that worked.
    Thank you.
    So we known that for in the future 😉 

  • Verified answer
    Pstork1 Profile Picture
    Pstork1 64,722 on at
    Re: set focus on a other control not working?

    If you temporarily add a button to the same container as the timer and set it to SetFocus(Button1) does the focus go where you want it to when you press the button? If yes, then its something in the timer code, if no, then its something about the setFocus(). As long as the containers are on the same screen it shouldn't matter. 

    Two other thoughts:

    1) Did you check the container to make sure that EnableChildFocus is set to True

    2) Button1 is just in a container and not in a gallery correct?

  • TimmyBoy Profile Picture
    TimmyBoy 997 on at
    Re: set focus on a other control not working?

    Hi @Pstork1 
    Whoops, my fault
    I forgot the code of the autostart

    If(CountRows(Gallery2.AllItems)>0;true;false)

    So when i type something in my TextInput control
    And it match some data on the hidden gallery
    the Autostart of the timer will run

  • Pstork1 Profile Picture
    Pstork1 64,722 on at
    Re: set focus on a other control not working?

    It looks like the timer autostart is set to false initially, so what event starts the timer? From the code you've shown I don't think the timer ever runs, so the SetFocus never executes.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard