mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Increased the movement tolerance for double-clicks when using a touch input source
This commit is contained in:
parent
a7055c3a96
commit
7e1ec31df9
1 changed files with 10 additions and 5 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue