Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Z4KGLxskVcGrrC1JNZRFuC
Power Apps - Building Power Apps
Unanswered

Select Label Text on focus

Like (0) ShareShare
ReportReport
Posted on 21 Aug 2020 18:04:46 by 1,142

Thank you for taking the time to read my question.

 

Is it possible to select the value that already exists inside a label or a Text Input when it receives the focus? 

 

On my Screen I have a drop down. When the user selects a value from the drop down I set the focus to my label. The Label's Text value is a Lookup, so I want to select the returned value when the label receives the focus.

 

Thanks!

 

 

Categories:
  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 28 Aug 2020 at 14:59:21
    Re: Select Label Text on focus

    Hi @iwonder 

     

    If you really want the ability to copy text from Power Apps, this might be useful for you: 

    https://powerusers.microsoft.com/t5/Webinars-and-Video-Gallery/Power-Apps-Copy-Text-To-Clipboard/td-p/556271

     

    Not sure how critical this functionality is for you, but may be worth an analysis to figure out if using a PCF control for this will be something that works for you. 

     

    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

  • iwonder Profile Picture
    1,142 on 28 Aug 2020 at 14:23:14
    Re: Select Label Text on focus

    Hi, sorry for my slow reply. I was called into other tasks but am back now.

     

    Yes I literally want to copy the value that is derived after the user makes selections from the dropdown boxes. We need to paste it into another system. This is a crude way of doing things I know but we have no other choice at the moment. 

     

    Thanks again

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 21 Aug 2020 at 21:59:20
    Re: Select Label Text on focus

    Do you want to literally copy the text or simply provide that as a starting point and allow users to override? Sorry if thats a dumb question. Just trying to understand the exact use case. 

     

    I have one other idea before I test it out. Add a label and then a text input control on top of it. Set the labels text to be based on the dropdown as discussed previously using Lookup(based on DropDown value selected by user))​;, then set the text input control's fill property to:

     

    If(IsBlank(Self.Text), Transparent, White)

     

    This was, when the focus is set on the text input control, they will see the text and can start typing in since the focus will be set on the text input control. 

     

    I will still try this out if this doesn't solve your use case since it sounds very interesting 🙂

     

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

     

    Thanks!
    Hardit Bhatia
    Microsoft Business Applications MVP
    https://thepoweraddict.com

  • iwonder Profile Picture
    1,142 on 21 Aug 2020 at 21:49:43
    Re: Select Label Text on focus

    Thanks again for your reply.

     

    Hint Text will not work. I want the users to be able to select the text.

     

    If you're curious to try and figure it out, great! But don't spend too much time on it. My users can just select the value in the label and then copy it. I was just hoping to save them a step.

     

     

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 21 Aug 2020 at 21:39:30
    Re: Select Label Text on focus

    Awesome explanation, thank you for that!

     

    One question I have is say when the label/text input control has the text "Test" written on it (from the example in the video), is there a possibility that the user doesn't update that value? Or the user will always have to type in something and update that Test to some other text? 

     

    If the user is always supposed to update that, you can achieve something similar by simply setting the text input control's Hint Text property in my suggested solution. Although when the focus is set to that text input control, the text would be blank. 

     

    I am not sure if we can achieve exactly what you want, but I will definitely try it out in some time and will get back to you. 

     

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

     

    Thanks!
    Hardit Bhatia
    Microsoft Business Applications MVP
    https://thepoweraddict.com

  • iwonder Profile Picture
    1,142 on 21 Aug 2020 at 20:32:33
    Re: Select Label Text on focus

    Hi,

     

    Thank you both for the replies. I've been reading and re-reading them....

     

    I can do what the gif shows already... I think, unless I'm missing something.

     

    You know when you're filling in a form on a web site and there are pre-populated values in some fields? Then when you click on a field, the pre-populated value is selected so that if you start typing the pre-existing value is overwritten?

     

    I want to select the value in the label or textinput when the label or textinput receives the focus.

     

    TEST.gif

    This is a form I found on the internet. The form flow is backwards but it shows what I mean. The focus moves from the yellow drop down to the Text: field. When I do a Shift+Alt+Tab the focus move up to the Text: field and the value that is existing in the text box is selected.

     

    Therefore, in my app I want to select a value from my dropdown. Once I do that, the lookup sets the value of my label and then the focus is set to the label. When the label receives the focus I would like the value to be selected just like "Test" is selected in the gif above.

     

    Am I doing any better explaining? I hope so. Thank you for your patience.

     

     

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 21 Aug 2020 at 19:32:47
    Re: Select Label Text on focus

    If you liked my replies, please give kudos (Thumbs Up). And if any of them solved your problem, please mark that 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

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 21 Aug 2020 at 19:07:37
    Re: Select Label Text on focus

    You can make it slightly easier. Here is another set of things that you can do to make this work: 

    1. Add a button and have its Text property set to testVar​
    2. I would probably use a Text Input control or a button than a label and set its text property to testVar
    3. In the OnChange of your drop down, have this code:  Set(testVar, Lookup(based on DropDown value selected by user))​; SetFocus(TextInput)​

    The reason for using Text Input control or a Button is because the focus will set on these controls and will be visible rather than on a label. Here is a quick demo: 

    Focus.gif 

    ---
    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

  • rubin_boer Profile Picture
    4,841 Super User 2024 Season 1 on 21 Aug 2020 at 19:05:57
    Re: Select Label Text on focus

    hi there, better now i understand thank you. im with @PowerAddict on this one. remember the input vs label.

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 21 Aug 2020 at 19:00:20
    Re: Select Label Text on focus

    You can achieve this with 2 functions: 

    1. Add a button and its on OnSelect, have Set(testVar, Lookup(based on DropDown value selected by user))​
    2. I would probably use a Text Input control than a label or what you can do is have a text input control hidden behind the label. - ​Have the text property of the text input control and the label set to testVar
    3. In the OnChange of your drop down, have this code: Select(Button); SetFocus(TextInput)​

    This should work. I will test it real quick and let you know if it works. If you get to test it before I do, let me know. 

     

    ---
    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started