Browse Source

Increased the movement tolerance for double-clicks when using a touch input source

tags/2021-05-28
ed 8 years ago
parent
commit
7e1ec31df9
1 changed files with 10 additions and 5 deletions
  1. +10
    -5
      modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp

+ 10
- 5
modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp View File

@@ -211,7 +211,8 @@ public:
if (auto* current = getComponentUnderMouse())
{
registerMouseDown (screenPos, time, *current, buttonState);
registerMouseDown (screenPos, time, *current, buttonState,
inputType == MouseInputSource::InputSourceType::touch);
sendMouseDown (*current, screenPos, time);
}
}
@@ -522,23 +523,26 @@ private:
Time time;
ModifierKeys buttons;
uint32 peerID = 0;
bool isTouch = false;
bool canBePartOfMultipleClickWith (const RecentMouseDown& other, int maxTimeBetweenMs) const noexcept
{
return time - other.time < RelativeTime::milliseconds (maxTimeBetweenMs)
&& std::abs (position.x - other.position.x) < 8
&& std::abs (position.y - other.position.y) < 8
&& std::abs (position.x - other.position.x) < getPositionToleranceForInputType()
&& std::abs (position.y - other.position.y) < getPositionToleranceForInputType()
&& buttons == other.buttons
&& peerID == other.peerID;
}
int getPositionToleranceForInputType() const noexcept { return isTouch ? 25 : 8; }
};
RecentMouseDown mouseDowns[4];
Time lastTime;
bool mouseMovedSignificantlySincePressed = false;
void registerMouseDown (Point<float> screenPos, Time time,
Component& component, const ModifierKeys modifiers) noexcept
void registerMouseDown (Point<float> screenPos, Time time, Component& component,
const ModifierKeys modifiers, bool isTouchSource) noexcept
{
for (int i = numElementsInArray (mouseDowns); --i > 0;)
mouseDowns[i] = mouseDowns[i - 1];
@@ -546,6 +550,7 @@ private:
mouseDowns[0].position = screenPos;
mouseDowns[0].time = time;
mouseDowns[0].buttons = modifiers.withOnlyMouseButtons();
mouseDowns[0].isTouch = isTouchSource;
if (auto* peer = component.getPeer())
mouseDowns[0].peerID = peer->getUniqueID();


Loading…
Cancel
Save