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? :?:
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=“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?