Is this possible?
Just make a ProgressBar widget, skin it to what you've shown, and add an event such that on Left Mouse Button down, you calculate the horizontal percentage of the cursor position vs the ProgressBar position. If you wanted to support LMB down and drag the value, you would want to add an event handler for DRAGGED.
The operations needed to do it are a little advanced, but I can help you out.
when i saw this post i tryed to do what you say, but when i add an event handler with addEventHandler() and set the event as mouse button down, and pass the function for the handler, the compiler gives me an error...
ok!, Already finished energy bar
how is the draged?
@Artic_Ice83: Hopefully you solved this, from the other thread.
This enables/simulates dragging, but actually performs no dragging, since the dragging widget is NULL.
For determining the position of the mouse cursor relative to the location of the progress bar, make sure you're using the following functions:
The AbsolutePosition reveals the true pixel coordinates on the screen, for example if your ProgressBar is inside a container that can scroll.
yes, i solved it. it was an error in the event name.
when i call setDraggingWidget(), what kind of widget i have to pass to the function?
Any widget you want! It would probably make send to pass the same instance of the widget and set that as the dragging widget.
Basically, when you click and drag the mouse over a widget, it will drag the draggingWidget.
The titlebar's parent is the window, so clicking and dragging the titlebar will drag the window, which moves the title bar. You could also do weird things, where clicking and dragging over an object will drag another object. If you want a simple case, where you can drag a button around, you would do
finally i did it! but instead of an event type DRAGGED, i used an EVENT_MOUSE_BUTTON_DOWN. The handler function get the position of the mouse, the actual position of the progress bar and the width. than sets the progress on the base of the position of the mouse relatively both position of the widget and its width.
but i didn't use the function getAbsolutePosition because i don't find it in my functions list. i've called the getActualPosition of the widget....but i suppose that if the widget is in a window or panel this call doesn't return the wanted result...
My mistake, its probably getActualPosition.
getActualPosition returns the pixel coordinates as it is shown on the screen, with 0,0 being the top left of the render window. So for example, it will tell you where a widget is between 0,0 to 800,600, or whatever your resolution is.
Setting the progress by clicking is a cool idea. Not unheard of, but I'm happy the current code base supports this without any addition, it means I've made things pretty flexible with minimal assumptions.
Everything works fine!
i love QuickGUI