cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jamarchi
Level: Powered On

How to clear a Text Input

Hi to all

 

I have this situatión, I have two screen, in the first one I have a text input in order the user type the name,one the user click the next button I filtered the information in the second screen, everything looks ok, the problem is when I return to the first screen I continue seeing the name of the user, how can I clear that information 

 

Thank you

2 ACCEPTED SOLUTIONS

Accepted Solutions
mr-dang
Level 10

Re: How to clear a Text Input

Ok, I see my error. Forget my first suggestion. That only works if you don't need that value in the textbox after typing it--i.e. clearing the username after someone clicks a button to login.

 

You can go with hngdev's suggestion if you want to carry the filtered table in a variable.

 

If you want to keep most things as they are, then you can try this:

 

Set Screen1.OnVisible to:

UpdateContext({resettext: !resettext});
UpdateContext({resettext: !resettext})

Set TextInput1.Reset to:

resettext

Set TextInput1.Default to:

""

 

Keep your filtered table the same.

 

This is how it works. Any time that you go to Screen1, the OnVisible actions will trigger. So it toggles the "resettext" variable to true, then back to false. The TextInput box will detect the change in the Reset property and reset the text to the Default value, which we set to "", which is blank.

 

If you navigate away from Screen1, the value in TextInput1 will stay the same. It will only reset when you go to Screen1.

Microsoft Employee
@8bitclassroom

View solution in original post

Mühle
Level: Powered On

Re: How to clear a Text Input

Hi,

 

You can use following OnSelect action for a button (I use an "cancel" icon on the right side of the textbox):

 

Reset(TextBoxName)

 

The text input will be cleared and will shown default value or hint text.

 

Best regards

View solution in original post

21 REPLIES 21
hngdev
Level 8

Re: How to clear a Text Input

What you can try this: 

  • OnVisible of Screen called Screen1 that contains TextInput controller: UpdateContext({filter: Left(filter,0)}) 
  • Default property of TextInput controller: filter
  • When navigate to other screens: Navigate(Screen2, Cover, {filter:TextInput.Text})
  • OnSelect on Button that navigates back to the first screen: Navigate(Screen1, ScreenTransition.Cover, {filter: " "}) //There should be a space between quotes

It should work.

mr-dang
Level 10

Re: How to clear a Text Input

Here's another way I learned from the templates.

 

Set the TextInput.Reset property to:

Button1.Pressed

Whenever the button is pressed, that will reset the TextInput.Text to whatever the default is--which, in your case, is "".

Microsoft Employee
@8bitclassroom
Jamarchi
Level: Powered On

Re: How to clear a Text Input

Hi and thank you to both of you for the answers

 

I tested both suggestion and both worked fine but has a problem, when I clicl the button the information in the text input is erased and it can´t be sent to the second screen

 

Thank you

hngdev
Level 8

Re: How to clear a Text Input

The way I approach is that I use a variable (filter) to store the text input data, when you click the button the Navigate function would wrap the filter variable and sent to the other screen. On the destination screen, you can use filter variable to get data.

Jamarchi
Level: Powered On

Re: How to clear a Text Input

Hi

 

But how and when do you store the value in a variable?

hngdev
Level 8

Re: How to clear a Text Input

You can have a check over on my answer above.

I initialize the variable in Screen1's OnVisible

Then, assign the variable to the text input.

Then, wrap the variable storing text input data and navigate to Screen2

On Screen2, you can use the variable.

mr-dang
Level 10

Re: How to clear a Text Input

Ok, I see my error. Forget my first suggestion. That only works if you don't need that value in the textbox after typing it--i.e. clearing the username after someone clicks a button to login.

 

You can go with hngdev's suggestion if you want to carry the filtered table in a variable.

 

If you want to keep most things as they are, then you can try this:

 

Set Screen1.OnVisible to:

UpdateContext({resettext: !resettext});
UpdateContext({resettext: !resettext})

Set TextInput1.Reset to:

resettext

Set TextInput1.Default to:

""

 

Keep your filtered table the same.

 

This is how it works. Any time that you go to Screen1, the OnVisible actions will trigger. So it toggles the "resettext" variable to true, then back to false. The TextInput box will detect the change in the Reset property and reset the text to the Default value, which we set to "", which is blank.

 

If you navigate away from Screen1, the value in TextInput1 will stay the same. It will only reset when you go to Screen1.

Microsoft Employee
@8bitclassroom

View solution in original post

hpkeong
Level 10

Re: How to clear a Text Input

Hi

 

Option1:

 

Dang's suggestion is correct. Maybe the way it is triggered.

1. You enter Name (in screen 1) in TextInput1; set the Reset: Button2.Pressed

2. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

3. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

4. In Screen1, you will see that TextInput1 entry is now cleared.

 

Reset: this can be triggered from another screen (global).

NB: When you click on Screen2 Button, the TextInput1 is cleared even before you navigate back to screen1.

 

Option 2:

 

You may also use UpdateContext, but this is local to the screen. 

NB: When you click on Screen2 Button, the TextInput1 is cleared ONLY when you are in screen1 (you can see the test is cleared just when you navigate into screen1).

 

 

1.  Insert a TextInput1 (in screen 1);

- under Default, say you name it: Default: MyText

- under OnVisible (Screen1), enter: OnVisible: UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

2. You enter Name (in screen 1) in TextInput1.

3. Click a button1 and navigate to Screen 2 (Button1, OnSelect: Navigate(Screen2, None))

4. Click a button2 and navigate back to Screen 1; (Button2: OnSelect: Navigate(Screen1, None))

5. In Screen1, you will see that TextInput1 entry is now cleared.

 

Always take note:

UpdateContext({MyText: " "}); UpdateContext({MyText: ""}).

" " - first one with space; "": second one with space.

Otherwise, you will never get your result.

 

They are numerous discussion over this with a lot of different options in Project Siena forum. https://social.technet.microsoft.com/Forums/en-US/de063751-7baa-41f0-af8d-20eb05126e40/how-do-i-clea...

 

Hoe this supplements the rests and helps.

hpkeong
Jamarchi
Level: Powered On

Re: How to clear a Text Input

Hi

 

Thank you very much for your help, finally It works, I followed the Dang's suggestion and now works as I espected

 

Thank you

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,496)