Need a hand with this component


#1

Hi folks, I’m in the process of building a controller component that has a movable item (a dot like on the linear sliders) inside a box of a preset width and height. I want to be able to read the x,y coordinates relative to a grid inside the box.

I built a component with Jucer that consisted of a Viewport, and (this is where my knowledge of components trails off) an ImageButton to produce the moveable dot… but I’m not sure how to implement the drag of the dot, since the drag classes seem to be concerned with dragging things to a target, but in this case the target is itself.

Any advice about what base components I should be using, and how to solve my “drag and drop” issue? :?:

Thanks for helping a new kid.


#2

ComponentDragger?


#3

You don’t use drag and drop for that - override Component::mouseDrag() instead. Also, the ViewPort is unnecessary, unless you want scrollbars.

I’m guessing you want a two dimensional slider. Or in other words, a type of slider control that allows you to set two independent values at the same time.


#4

And here we go:

http://code.google.com/p/juced/source/browse/trunk/juce/src/extended/controls/jucetice_Joystick.h
http://code.google.com/p/juced/source/browse/trunk/juce/src/extended/controls/jucetice_Joystick.cpp

You can download the whole juced module from here, you will find a lot of useful stuff in it :smiley:
http://code.google.com/p/juced/downloads/list


#5

[quote=“TheVinn”]You don’t use drag and drop for that - override Component::mouseDrag() instead. Also, the ViewPort is unnecessary, unless you want scrollbars.

I’m guessing you want a two dimensional slider. Or in other words, a type of slider control that allows you to set two independent values at the same time.[/quote]

Yes, a two-dimensional slider is exactly what I need. I looked for something like that but I didn’t see anything. So I take it I can just make a component (an ImageButton?), override the mouseDown and mouseDrag methods, and then put a constraint on where I can move the object? As far as getting the coordinates, what will they be relative to?

[quote=“masshacker”]And here we go:

http://code.google.com/p/juced/source/browse/trunk/juce/src/extended/controls/jucetice_Joystick.h
http://code.google.com/p/juced/source/browse/trunk/juce/src/extended/controls/jucetice_Joystick.cpp

You can download the whole juced module from here, you will find a lot of useful stuff in it :smiley:
http://code.google.com/p/juced/downloads/list[/quote]

Looks solid, I’m taking a look now… thanks everyone!