An object to take care of the logic for dragging components around with the mouse. More...
#include <juce_ComponentDragger.h>
Public Member Functions | |
ComponentDragger () | |
Creates a ComponentDragger. More... | |
virtual | ~ComponentDragger () |
Destructor. More... | |
void | dragComponent (Component *componentToDrag, const MouseEvent &e, ComponentBoundsConstrainer *constrainer) |
Call this from your mouseDrag() callback to move the component. More... | |
void | startDraggingComponent (Component *componentToDrag, const MouseEvent &e) |
Call this from your component's mouseDown() method, to prepare for dragging. More... | |
Private Attributes | |
Point< int > | mouseDownWithinTarget |
An object to take care of the logic for dragging components around with the mouse.
Very easy to use - in your mouseDown() callback, call startDraggingComponent(), then in your mouseDrag() callback, call dragComponent().
When starting a drag, you can give it a ComponentBoundsConstrainer to use to limit the component's position and keep it on-screen.
e.g.
@tags{GUI}
juce::ComponentDragger::ComponentDragger | ( | ) |
Creates a ComponentDragger.
|
virtual |
Destructor.
void juce::ComponentDragger::dragComponent | ( | Component * | componentToDrag, |
const MouseEvent & | e, | ||
ComponentBoundsConstrainer * | constrainer | ||
) |
Call this from your mouseDrag() callback to move the component.
This will move the component, using the given constrainer object to check the new position.
componentToDrag | the component that you want to drag |
e | the current mouse-drag event |
constrainer | an optional constrainer object that should be used to apply limits to the component's position. Pass null if you don't want to constrain the movement. |
void juce::ComponentDragger::startDraggingComponent | ( | Component * | componentToDrag, |
const MouseEvent & | e | ||
) |
Call this from your component's mouseDown() method, to prepare for dragging.
componentToDrag | the component that you want to drag |
e | the mouse event that is triggering the drag |