Browse Source

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

tags/2021-05-28
ed 9 years ago
parent
commit
1e7a933543
2 changed files with 17 additions and 1 deletions
  1. +12
    -0
      modules/juce_gui_basics/components/juce_Component.h
  2. +5
    -1
      modules/juce_gui_basics/layout/juce_Viewport.cpp

+ 12
- 0
modules/juce_gui_basics/components/juce_Component.h 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


+ 5
- 1
modules/juce_gui_basics/layout/juce_Viewport.cpp 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;
}


Loading…
Cancel
Save