Snapping with componentDragger?

Is there an easy way to enabling snapping(snap to grid) with a componentDragger? Right now I’m doing it rather crudely in the component mouseDrag method:

void MyComp::mouseDrag(const MouseEvent& e){
//pos hold the position of the component before dragging starts
		x = e.getDistanceFromDragStartX();
		y = e.getDistanceFromDragStartY();
	setTopLeftPosition(x+pos.getX(), y+pos.getY());

But I’d rather do it using a componentDragger if it’s possible?

Take a look at ComponentBoundsConstrainer - I believe you’ll want to put your snapping logic into the checkBounds function. You’d then keep an instance of your constrainer subclass around somewhere, and pass a pointer to it to the ComponentDragger::dragComponent calls.

Thanks haydxn, this should get me started. btw, I’m still using your ComponentLayoutEditor class! I’ve hacked it to pieces at this stage, but I’d be lost without it!