-1

I have tried to access the PreviewMouseLeftButtonUp as suggested here

But it is not available in UWP.

For now I just have:

btnLower.KeyUp += BtnLower_KeyUp; // keyboard
btnLower.PointerReleased += BtnLower_PointerReleased; // seems only touch input

The KeyUp seems to work for keyboard input as expected. The PointerReleased does not work with stylus/pen input or mouse input. So how do I respond to the event when the RepeatButton stops to fire the click event?

I use the click event to just increase or decrease an int value and want to store that value when the change (increase/decrease) is done. And I would like it to respond to pen/touch/mouse and keyboard input.

edit for @Sasha

enter image description here

Community
  • 1
  • 1
JP Hellemons
  • 5,977
  • 11
  • 63
  • 128

1 Answers1

0

You could throttle your code that stores the value to make it only do that when no updates have occurred for a while. That way you won't have to hack around the input stack.

You could try using a custom VisualStateManager in the button template that will trigger an event when the visual state changes from pressed to neutral, but that seems a bit hacky and unnecessary.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
  • So there is no native event which I can subscribe to? The other option to limit the amount of commits is to set the interval of the repeatbutton higher so that it does not fire so many click events and just commit every fired click event. That seems to be my only option atm. Thanks for your suggestion, but it seems an overkill for what I am trying to do. – JP Hellemons Dec 21 '16 at 11:26
  • Well, at least that would handle the case when someone repeatedly clicks the button to the same effect as holding it, which isn't uncommon. – Filip Skakun Dec 22 '16 at 05:52