cancel
Showing results for 
Search instead for 
Did you mean: 

How-to get double-click events in PowerApps

One click should be one-click and double-click should be two clicks. Makes sense right 🙂 But what when someone keeps clicking? I have 2 patterns. In both cases, a button and a timer control are used. Labels are used in the demo (video) for visual feedback. The patterns are:

  1. A fixed time to click.
  2. The timer is reset after each click.

Pattern #1

The screen has 2 buttons. One for the clicks and one to acknowledge a message. This button is only shown after the time set has passed. The click button is disabled after the time has passed.

The click button has the following code in the property "OnSelect":

UpdateContext({var_Text: "-"});
Switch(
     var_Click,
     0,
     UpdateContext({var_Click: 1});
     UpdateContext({var_TimerStart: false});
     UpdateContext({var_TimerStart: true}),
     1,
     UpdateContext({var_Click: 2}),
     2,
     UpdateContext({var_Click: 3}),
     3,
     UpdateContext({var_Click: 3})
 )
  • The property "Start" of the timer control contains the variable "var_TimerStart".
  • The property "Duration" of the timer control contains the variable "var_Duration". This value is set at the property "OnVisble" of the screen and set to "400". I found this value to be the most intuitive but please do test what you like.

The property "OnTimerEnd" of the timer control has the following code:

UpdateContext({var_DisableButton: true});
Switch(
     var_Click,
     1,
     UpdateContext({var_Text: "Single Click"}),
     2,
     UpdateContext({var_Text: "Double Click"}),
     3,
     UpdateContext({var_Text: "Multi Click"})
 );
 UpdateContext({var_Click: 0});
 UpdateContext({var_BtnVisble: true})

Pattern #2

The only real difference between pattern #1 and pattern #2 is the property "OnSelect" of the click button. The button has the following code in the property "OnSelect":

UpdateContext({var_Text: "-"});
Switch(
     var_Click,
     0,
     UpdateContext({var_Click: 1});
     UpdateContext({var_TimerStart: false});
     UpdateContext({var_TimerStart: true}),
     1,
     UpdateContext({var_Click: 2});
     Reset(Timer2_1);
     UpdateContext({var_TimerStart: false});
     UpdateContext({var_TimerStart: true}),
     2,
     UpdateContext({var_Click: 3});
     Reset(Timer2_1);
     UpdateContext({var_TimerStart: false});
     UpdateContext({var_TimerStart: true}),
     3,
     UpdateContext({var_Click: 3});
     Reset(Timer2_1);
     UpdateContext({var_TimerStart: false});
     UpdateContext({var_TimerStart: true})
)

As you can see, after each click, the timer control is reset. This makes it possible to keep clicking.

The video below gives more visual explanation.

 

 

Comments

Thats a real goo idea man. Great work

Advocate I

@Rick72 I use your solution in bespoke calendar, where I click a start and end date. On doubleclick I set the start and enddate to the same date. Which I would not have managed without seeing your solution, Thanks.

On double click the Start and End date are the same:

 

SameStartEndDate.PNG

 

 

 

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim