1

I recently created a custom entry pad with buttons that the user may be clicking rapidly (it is basically a custom numeric entry pad). The problem is that if the button tapped event is used to register the handler for the entry pad key it responds so slowly that button presses are missed (meaning if I rapidly press the number 2 five times, maybe 2 or 3 twos show up). Changing the event from Tapped to Clicked (same code otherwise) causes the entry pad to be fully responsive.

Why is it that the Tapped event handler is so unresponsive and is are there any potential repercussions for using the Tapped instead of the Clicked handler?

Chiune Sugihara
  • 1,179
  • 1
  • 7
  • 14

2 Answers2

2

I haven't used it enough to verify, but it's likely to support double tapped events. Perhaps if you set IsDoubleTapEnabled to false then tap events will come in sooner.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
  • That is a really good idea, but unfortunately it doesn't work. There is still a major difference between Tapped and Click when IsDoubleTapEnabled is set to false. To give an idea of how bad it is, when I rapidly click the digits 1 thru 9, I get all the digits when the click handler is used and only one or two when Tapped is used with IsDoubleTapEnabled set to false. The buttons themselves are RepeatButtons if that makes any difference. – Chiune Sugihara Feb 20 '14 at 05:11
  • Sorry for taking so long to respond. I spent some time trying to recreate and found that just a simple app with a textblock and a button will reproduce the issue. Every time the button is tapped the handler adds a letter to the textblock. By counting how many times I hit the left mouse button I was able to compare the actual number of "taps" to the number that were registered as letters in the textblock. I found that only around half of my taps were actually causing calls to the Tapped event handler. This was running in debug mode (local machine) with VS2013 express. – Chiune Sugihara Mar 30 '14 at 03:19
  • I'd suppose the `Tapped` event is there for handling single taps. If you need to handle all clicks - handle the `Click` event. If you want to get into more details - handle the `Pointer~` events. – Filip Skakun Mar 30 '14 at 23:43
  • I guess it must be something like that, or else there is some sort of delay after a tap during which point any other incoming taps are ignored. From reading about the two it comes across as Click is legacy and Tapped is the one to use ([see this article](http://stackoverflow.com/questions/13318569/are-click-tapped-and-pointerpressed-synonymous-in-winrt-xaml)), so it is kind of strange that Click is the more accurate of the two from a user's perspective. But you are probably right, there is likely some design issue that causes this. – Chiune Sugihara Apr 01 '14 at 02:15
  • I think the answer you linked is inaccurate. I don't know what the reasoning was behind `Click` and `Tapped` events, but I would assume a `Click` event that only exists on `ButtonBase` is supposed to be used for buttons, while `Tapped` is something that works on all controls and is more of a gesture than an action. You click a XAML button, but you can tap anything. Clicking is associated with all the logic of a button. Tapping is simply tapping. – Filip Skakun Apr 01 '14 at 05:41
  • I am having the same problem Chiune is having. Only about half of my Tap events actually make it through to my event handler. I tried using PointerReleased and I'm receiving all of the events now. – Kenny Wyland Aug 29 '14 at 19:59
  • I tried using the original Tapped + IsDoubleTapEnabled=false and that did not solve the problem. Only using the PointerReleased event got me all of the events I wanted. – Kenny Wyland Aug 29 '14 at 20:07
1

This answer really comes from Filip Skakun's comments on the other answer he gave on this post, but to make it easy for people to find this answer, I'm going to post it separately. If Filip edits his answer or posts this as a new one, I'll remove mine so that he's can be the one getting the credit.

The solution that worked for me was to use the PointerReleased event instead of the Tapped event. When using Tapped I only received about half of my events if the clicks/taps were in quick succession. However, if I used PointerReleased instead, then I received all of my events.

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • It's fine to have a separate answer here. I'd just like to point that `PointerReleased` alone might not be enough since you would likely also want to make sure that the matching `PointerPressed` from the same source was raised on your element and you'd probably need to call `CapturePointer()`. Also limiting the maximum time between the events might be desirable. – Filip Skakun Aug 29 '14 at 21:35