1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added viewportIgnoreDragFlag to Component to indicate that mouse drag events should not move the Component's parent Viewport with drag-to-scroll functionality enabled.

This commit is contained in:
ed 2017-03-28 15:44:49 +01:00
parent aad868e383
commit 1e7a933543
2 changed files with 17 additions and 1 deletions

View file

@ -2230,6 +2230,17 @@ public:
*/
CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage; }
/** Sets a flag to indicate whether mouse drag events on this Component should be ignored when it is inside a
Viewport with drag-to-scroll functionality enabled. This is useful for Components such as sliders that
should not move their parent Viewport when dragged.
*/
void setViewportIgnoreDragFlag (bool ignoreDrag) { flags.viewportIgnoreDragFlag = ignoreDrag; };
/** Retrieves the current state of the Viewport drag-to-scroll functionality flag.
@see setViewportIgnoreDragFlag
*/
bool getViewportIgnoreDragFlag() { return flags.viewportIgnoreDragFlag; }
//==============================================================================
// These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead.
JUCE_DEPRECATED (Point<int> relativePositionToGlobal (Point<int>) const);
@ -2288,6 +2299,7 @@ private:
bool mouseDownWasBlocked : 1;
bool isMoveCallbackPending : 1;
bool isResizeCallbackPending : 1;
bool viewportIgnoreDragFlag : 1;
#if JUCE_DEBUG
bool isInsidePaintCall : 1;
#endif

View file

@ -211,8 +211,12 @@ struct Viewport::DragToScrollListener : private MouseListener,
(int) offsetY.getPosition()));
}
void mouseDown (const MouseEvent&) override
void mouseDown (const MouseEvent& e) override
{
for (auto c = e.eventComponent; c != nullptr && c != &viewport; c = c->getParentComponent())
if (c->getViewportIgnoreDragFlag())
return;
++numTouches;
}