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:
parent
aad868e383
commit
1e7a933543
2 changed files with 17 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue