Possible bug in HWNDComponentPeer::handlePenInput()


I found mouseUp calls were missing in some cases when testing with the pen on a Microsoft Surface. I can reproduce the problem I was seeing using the JuceDemo as follows:

  1. launch JuceDemo
  2. open the Components:Animation demo tab
  3. click on “Drag Me!” button using mouse
  4. release mouse button while making sure to leave the mouse cursor inside the “Drag Me!” button bounds
  5. press inside the “Drag Me!” button with the pen
  6. lift the pen off the screen (being careful not to drag the button, so mouse position stays inside it)
  7. move the mouse around – the “Drag Me!” button is dragged even though no mouse buttons are down on it anymore

I’m not sure that this is the correct fix, but adding these two lines to clear the mouse buttons from the currentModifiers when no buttons are pressed fixes it for me:

  if ((pInfoFlags & POINTER_FLAG_FIRSTBUTTON) != 0)
      currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
  else if ((pInfoFlags & POINTER_FLAG_SECONDBUTTON) != 0)
      currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::rightButtonModifier);
+ else 
+     currentModifiers = currentModifiers.withoutMouseButtons();

Thanks for taking a look!


Thanks, I’ll sort that out.

Great, thanks!