ComponentDragger Class Reference

An object to take care of the logic for dragging components around with the mouse. More...

List of all members.

Public Member Functions

 ComponentDragger ()
 Creates a ComponentDragger.
virtual ~ComponentDragger ()
 Destructor.
void startDraggingComponent (Component *const componentToDrag, ComponentBoundsConstrainer *constrainer)
 Call this from your component's mouseDown() method, to prepare for dragging.
void dragComponent (Component *const componentToDrag, const MouseEvent &e)
 Call this from your mouseDrag() callback to move the component.

Detailed Description

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.

    class MyDraggableComp
    {
        ComponentDragger myDragger;

        void mouseDown (const MouseEvent& e)
        {
            myDragger.startDraggingComponent (this, 0);
        }

        void mouseDrag (const MouseEvent& e)
        {
            myDragger.dragComponent (this, e);
        }
    };

Constructor & Destructor Documentation

ComponentDragger::ComponentDragger (  ) 

Creates a ComponentDragger.

virtual ComponentDragger::~ComponentDragger (  )  [virtual]

Destructor.


Member Function Documentation

void ComponentDragger::startDraggingComponent ( Component *const   componentToDrag,
ComponentBoundsConstrainer constrainer 
)

Call this from your component's mouseDown() method, to prepare for dragging.

Parameters:
componentToDrag the component that you want to drag
constrainer a constrainer object to use to keep the component from going offscreen
See also:
dragComponent
void ComponentDragger::dragComponent ( Component *const   componentToDrag,
const MouseEvent e 
)

Call this from your mouseDrag() callback to move the component.

This will move the component, but will first check the validity of the component's new position using the checkPosition() method, which you can override if you need to enforce special positioning limits on the component.

Parameters:
componentToDrag the component that you want to drag
e the current mouse-drag event
See also:
dragComponent

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:11 2010 for JUCE by  doxygen 1.6.3