JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::ComponentDragger Class Reference

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.
 
virtual ~ComponentDragger ()
 Destructor.
 
void startDraggingComponent (Component *componentToDrag, const MouseEvent &e)
 Call this from your component's mouseDown() method, to prepare for dragging.
 
void dragComponent (Component *componentToDrag, const MouseEvent &e, ComponentBoundsConstrainer *constrainer)
 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.

{
ComponentDragger myDragger;
void mouseDown (const MouseEvent& e)
{
myDragger.startDraggingComponent (this, e);
}
void mouseDrag (const MouseEvent& e)
{
myDragger.dragComponent (this, e, nullptr);
}
};
An object to take care of the logic for dragging components around with the mouse.
void dragComponent(Component *componentToDrag, const MouseEvent &e, ComponentBoundsConstrainer *constrainer)
Call this from your mouseDrag() callback to move the component.
void startDraggingComponent(Component *componentToDrag, const MouseEvent &e)
Call this from your component's mouseDown() method, to prepare for dragging.
Contains position and status information about a mouse event.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88

@tags{GUI}

Definition at line 58 of file juce_ComponentDragger.h.

Constructor & Destructor Documentation

◆ ComponentDragger()

juce::ComponentDragger::ComponentDragger ( )

Creates a ComponentDragger.

Definition at line 29 of file juce_ComponentDragger.cpp.

◆ ~ComponentDragger()

juce::ComponentDragger::~ComponentDragger ( )
virtual

Destructor.

Definition at line 30 of file juce_ComponentDragger.cpp.

Member Function Documentation

◆ dragComponent()

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.

Parameters
componentToDragthe component that you want to drag
ethe current mouse-drag event
constraineran 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.
See also
startDraggingComponent

Definition at line 42 of file juce_ComponentDragger.cpp.

◆ startDraggingComponent()

void juce::ComponentDragger::startDraggingComponent ( Component componentToDrag,
const MouseEvent e 
)

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

Parameters
componentToDragthe component that you want to drag
ethe mouse event that is triggering the drag
See also
dragComponent

Definition at line 33 of file juce_ComponentDragger.cpp.


The documentation for this class was generated from the following files: