mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-18 00:54:19 +00:00
Deprecated MouseInputSource::hasMouseMovedSignificantlySincePressed() and replaced with the more accurate isLongPressOrDrag() and hasMovedSignificantlySincePressed() methods
This commit is contained in:
parent
a82047aea9
commit
7cf8e28fdd
3 changed files with 36 additions and 14 deletions
|
|
@ -2379,7 +2379,7 @@ void Component::internalMouseUp (MouseInputSource source, Point<float> relativeP
|
|||
getLocalPoint (nullptr, source.getLastMouseDownPosition()),
|
||||
source.getLastMouseDownTime(),
|
||||
source.getNumberOfMultipleClicks(),
|
||||
source.hasMouseMovedSignificantlySincePressed());
|
||||
source.hasMovedSignificantlySincePressed());
|
||||
mouseUp (me);
|
||||
|
||||
if (checker.shouldBailOut())
|
||||
|
|
@ -2418,7 +2418,7 @@ void Component::internalMouseDrag (MouseInputSource source, Point<float> relativ
|
|||
getLocalPoint (nullptr, source.getLastMouseDownPosition()),
|
||||
source.getLastMouseDownTime(),
|
||||
source.getNumberOfMultipleClicks(),
|
||||
source.hasMouseMovedSignificantlySincePressed());
|
||||
source.hasMovedSignificantlySincePressed());
|
||||
mouseDrag (me);
|
||||
|
||||
if (checker.shouldBailOut())
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ public:
|
|||
{
|
||||
int numClicks = 1;
|
||||
|
||||
if (! hasMouseMovedSignificantlySincePressed())
|
||||
if (! isLongPressOrDrag())
|
||||
{
|
||||
for (int i = 1; i < numElementsInArray (mouseDowns); ++i)
|
||||
{
|
||||
|
|
@ -405,10 +405,20 @@ public:
|
|||
return numClicks;
|
||||
}
|
||||
|
||||
bool isLongPressOrDrag() const noexcept
|
||||
{
|
||||
return movedSignificantly || lastTime > mouseDowns[0].time + RelativeTime::milliseconds (300);
|
||||
}
|
||||
|
||||
bool hasMovedSignificantlySincePressed() const noexcept
|
||||
{
|
||||
return movedSignificantly;
|
||||
}
|
||||
|
||||
// Deprecated method
|
||||
bool hasMouseMovedSignificantlySincePressed() const noexcept
|
||||
{
|
||||
return mouseMovedSignificantlySincePressed
|
||||
|| lastTime > mouseDowns[0].time + RelativeTime::milliseconds (300);
|
||||
return isLongPressOrDrag();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -539,7 +549,7 @@ private:
|
|||
|
||||
RecentMouseDown mouseDowns[4];
|
||||
Time lastTime;
|
||||
bool mouseMovedSignificantlySincePressed = false;
|
||||
bool movedSignificantly = false;
|
||||
|
||||
void registerMouseDown (Point<float> screenPos, Time time, Component& component,
|
||||
const ModifierKeys modifiers, bool isTouchSource) noexcept
|
||||
|
|
@ -557,14 +567,13 @@ private:
|
|||
else
|
||||
mouseDowns[0].peerID = 0;
|
||||
|
||||
mouseMovedSignificantlySincePressed = false;
|
||||
movedSignificantly = false;
|
||||
lastNonInertialWheelTarget = nullptr;
|
||||
}
|
||||
|
||||
void registerMouseDrag (Point<float> screenPos) noexcept
|
||||
{
|
||||
mouseMovedSignificantlySincePressed = mouseMovedSignificantlySincePressed
|
||||
|| mouseDowns[0].position.getDistanceFrom (screenPos) >= 4;
|
||||
movedSignificantly = movedSignificantly || mouseDowns[0].position.getDistanceFrom (screenPos) >= 4;
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInputSourceInternal)
|
||||
|
|
@ -605,7 +614,8 @@ void MouseInputSource::triggerFakeMove() const
|
|||
int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); }
|
||||
Time MouseInputSource::getLastMouseDownTime() const noexcept { return pimpl->getLastMouseDownTime(); }
|
||||
Point<float> MouseInputSource::getLastMouseDownPosition() const noexcept { return pimpl->getLastMouseDownPosition(); }
|
||||
bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); }
|
||||
bool MouseInputSource::isLongPressOrDrag() const noexcept { return pimpl->isLongPressOrDrag(); }
|
||||
bool MouseInputSource::hasMovedSignificantlySincePressed() const noexcept { return pimpl->hasMovedSignificantlySincePressed(); }
|
||||
bool MouseInputSource::canDoUnboundedMovement() const noexcept { return ! isTouch(); }
|
||||
void MouseInputSource::enableUnboundedMouseMovement (bool isEnabled, bool keepCursorVisibleUntilOffscreen) const
|
||||
{ pimpl->enableUnboundedMouseMovement (isEnabled, keepCursorVisibleUntilOffscreen); }
|
||||
|
|
@ -640,6 +650,9 @@ const float MouseInputSource::invalidRotation = 0.0f;
|
|||
const float MouseInputSource::invalidTiltX = 0.0f;
|
||||
const float MouseInputSource::invalidTiltY = 0.0f;
|
||||
|
||||
// Deprecated method
|
||||
bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); }
|
||||
|
||||
//==============================================================================
|
||||
struct MouseInputSource::SourceList : public Timer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -172,10 +172,12 @@ public:
|
|||
/** Returns the screen position at which the last mouse-down occurred. */
|
||||
Point<float> getLastMouseDownPosition() const noexcept;
|
||||
|
||||
/** Returns true if this mouse is currently down, and if it has been dragged more
|
||||
than a couple of pixels from the place it was pressed.
|
||||
*/
|
||||
bool hasMouseMovedSignificantlySincePressed() const noexcept;
|
||||
/** Returns true if this input source represents a long-press or drag interaction i.e. it has been held down for a significant
|
||||
amount of time or it has been dragged more than a couple of pixels from the place it was pressed. */
|
||||
bool isLongPressOrDrag() const noexcept;
|
||||
|
||||
/** Returns true if this input source has been dragged more than a couple of pixels from the place it was pressed. */
|
||||
bool hasMovedSignificantlySincePressed() const noexcept;
|
||||
|
||||
/** Returns true if this input source uses a visible mouse cursor. */
|
||||
bool hasMouseCursor() const noexcept;
|
||||
|
|
@ -235,6 +237,13 @@ public:
|
|||
static const float invalidTiltX;
|
||||
static const float invalidTiltY;
|
||||
|
||||
#if ! DOXYGEN
|
||||
// This method has been deprecated and replaced with the isLongPressOrDrag() and hasMovedSignificantlySincePressed()
|
||||
// methods. If you want the same behaviour you should use isLongPressOrDrag() which accounts for the amount of time
|
||||
// that the input source has been held down for, but if you only want to know whether it has been moved use
|
||||
// hasMovedSignificantlySincePressed() instead.
|
||||
JUCE_DEPRECATED (bool hasMouseMovedSignificantlySincePressed() const noexcept);
|
||||
#endif
|
||||
private:
|
||||
//==============================================================================
|
||||
friend class ComponentPeer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue