PowerApps Peninput conditional reset workaround
Hi All,
Issue: PowerApps Peninput won't reset if the pen input is not in active screen. Onvisible = Reset(Peninput) does not work.
Solution: Create a timer with context variable trigger and trigger the context variable from OnVisible from a screen that peninput locates.
Demo:
Assume that there are 2 Scrrens, Screen1 is empty, Screen2 has one pen input. Peninput in Screen2 needs to be reseted (Cleared) on cirtain circumstance.
Step 1. Create Screens and navigations as follows
Screen1: Label and button that navigates to Screen2
Screen2: Same as Screen1 with extra Pen input
Step 2. Change OnVisible Property of Screen2 to following code.
If(locPenReset,
//Local variable that triggers timer. Turn it off and on the context variable
UpdateContext({locTimerStart:false});UpdateContext({locTimerStart:true});
UpdateContext({locPenReset:false});
)
Step 3. Create a Timer in Screen 2 and Change the properties.
Duration:
1
Start:
locTimerStart
OnTimerEnd:
Reset(PenInput1)
Step 4. Create a button with following property in Screen1
OnSelect:
Navigate(Screen2,None,{locPenReset: true})
Result: Nav Button on Screen1 will navigate to Screen2 but not resetting the pen input. Nav with reset button will navigate to Screen2 and reset the peninput.
Note:
- Because the resetting the pen input happens after screen draws so the user might see previous drawing for a moment.
- Condition on If statement in Screen2 OnVisible can be changed to meet apps expected behaviour (i.e. reset when current drawing is submitted and new drawing is started.
File attached to test with ease.