Page 1 of 1
Tap "cancel" on an input dialog
Posted: 20 Mar 2020 18:36
by tsolignani
Good evening everyone.
Sometimes I tap cancel by mistake and lose the text I was entering or the thing I was doing.
Is there a way to ask for a confirmation when the user press cancel on an input dialog?
I suppose the text that was into the dialog box does not populate the value variable, is there a way to retrieve it?
Thank you.
Re: Tap "cancel" on an input dialog
Posted: 20 Mar 2020 20:57
by Micky Micky
Hello
Cancel seems to lose the input.
You can create a confirmation dialog for the cancel button but the input is still lost.
Hopefully someone might have a workaround.
Good luck
Micky
Re: Tap "cancel" on an input dialog
Posted: 20 Mar 2020 21:13
by tsolignani
Thank you.
That's the matter, no point in doing a confirmation dialog if the input is lost anyway.
Let's see if someone else has something to say.
Thank you.
Re: Tap "cancel" on an input dialog
Posted: 20 Mar 2020 22:20
by Micky Micky
Hello
It's possible.
UI EVENT trigger can watch for Input Dialog WINDOW OPENED. This enables another flow with UI EVENT trigger watching for TEXT CHANGED.
I set it to watch for 1234 being typed and it triggered and returned a variable containing 1234.
This could be written to a text file until you press OK on your Input Dialog.
What I don't know is the Regex or Glob pattern to get it to watch for the whole keyboard.
I don't have time to show you a working example, but here's the bit watching for the 1234. The variable returned is called 'text'
http://automagic4android.com/flow.php?i ... ae536dabb9
Hope this helps
Micky
Re: Tap "cancel" on an input dialog
Posted: 21 Mar 2020 05:56
by Rafi4
Hi tsolignani
Action input dialog default value as global_a
Action script as example global_a = value;
Condition confirmation dialog as in screen shot
I hope I have explained better
from record4
Re: Tap "cancel" on an input dialog
Posted: 21 Mar 2020 17:32
by Desmanto
It can be done by using Control UI. Put a control UI parallel to the input dialog (so both get executed at the same time). Both input dialog and control UI connected to previous same element.
Code: Select all
sleep(1000);
while(existsElementById("android:id/alertTitle"))
{
savedtext = getTextById("ch.gridvision.ppam.androidautomagic:id/edit_text");
sleep(1000);
}
This CUI script will loop every second and save the text in the input field to the [savedtext} variable. If you accidentally press cancel, you can still use {savedtext} as the output result. Check it using script after the input dialog. The Control UI ends there, not connected to any other element after it.
Re: Tap "cancel" on an input dialog
Posted: 22 Mar 2020 13:06
by tsolignani
Thank you everybody.
I guess Desmanto solution did the trick.
It works, I put a block with that code and if cancel gets hit by mistake its content get copied to the clipboard.
You could imagine even stricter solutions, like writing the variable to a file maybe, so that you are safe even when the phone crash or does otherwise.
Thanks again, wonderful app and wonderful forum!