web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Select Label Text on f...
Power Apps
Unanswered

Select Label Text on focus

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • rubin_boer Profile Picture
    4,841 Super User 2024 Season 1 on at

    hi there not too sure what it is you trying to achieve. when you select the dropdown value, the "focus" is still on the dropdown whic selected you assign to a variable and have that reflect in the label or use that to lookup a value and set the return value to the label. either way you will have the returned value. maybe if you can give some screenshots of what you want to achieve it will be great. tnx

  • iwonder Profile Picture
    1,142 on at

    Thank you for your reply. Sorry I was not very clear.

     

    I'll try to explain using steps:

    1. User selects value from DropDown

    1a. DropDown OnChange = SetFocus(Label1)

    2. Label1.Text = Lookup(based on DropDown value selected by user)

     

    Therefore, once the user makes a selection in the DropDown, Label1 value is set and Label1 receives the focus. Since it is not possible to copy a value to the clipboard (using app on PC only) I was hoping to pre-select the value for the user so all they have to do is Ctrl+C to copy saving them a bit of mouse or keyboard work to select the Label1 value.

     

    Better? 🙂

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    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

  • rubin_boer Profile Picture
    4,841 Super User 2024 Season 1 on at

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

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    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

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    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

  • iwonder Profile Picture
    1,142 on at

    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,316 Most Valuable Professional on at

    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 at

    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,316 Most Valuable Professional on at

    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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard