Problem dragging a component


#1

I’m thinking about making a very simple flowcharting program, but I don’t have much experience actually making a JUCE project from scratch. So, I figured I’d try making a simple draggable rectangle component and adding it to the miscellaneous tab on the widgets demo. But, I can’t get the dragging to work.

[code]class RectangleComp : public Component
{
Colour x;
ComponentDragger dragger;
public:
RectangleComp() {
x = Colours::green;
}

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

void paint(Graphics &g) {
	g.fillAll (x);
}

};[/code]

And here’s the bit where I add it to the miscellaneous comp:

RectangleComp* rc = new RectangleComp(); page->addAndMakeVisible(rc); rc->setBounds (300, 100, 200, 100);

I can’t see how I’m doing anything substantially different from the DragOntoDesktopDemoComp.


#2

There’s no better solution to a problem like this than posting the question on a public forum. Most of the time I’ll figure it out on my own. Guess I just forgot to implement the mouseDrag function. Whoops. :oops:


#3

if you could so a searcj just on the oops icon, you’d find a depressing[1] number of threads that basically go : “how do I?” followed by “I’m an idiot”

[1] depressing 'cos a fair chunk of them are mine. :oops:


#4

In a somewhat related problem, I was earlier trying to work with the mouseEnter and mouseExit events, and couldn’t figure out why the simple hover code I put in didn’t seem to work. Eventually it dawned on me that I wasn’t doing a repaint.

Oh well, if I actually go through with this making this flowchart app, I’m sure I’ll be using ;oops; on this forum a few dozen more times.


#5

[quote=“valley”]if you could so a searcj just on the oops icon, you’d find a depressing[1] number of threads that basically go : “how do I?” followed by “I’m an idiot”

[1] depressing 'cos a fair chunk of them are mine. :oops:[/quote]

few o mine in there too but I dont use the icon


#6