On 02/06/2010 12:42 PM, Jens Grunert wrote:
> Could you tell me how to modify the example:
> http://seriss.com/people/erco/fltk/#DraggableBoxes
> So that when i select the box is gets pushed into foreground?

Interesting problem.  It seems that the boxes are drawn in the order of 
the child array of the scroll widget.  So what you have to do is make 
the picked up widget the last one in that array.  You can do this by 
subclassing Fl_Scroll and adding a method to do this.  The following 
draws heavily from Fl_Scroll::fix_scrollbar_order().

class Scroll : public Fl_Scroll
{
public:
    Scroll(int X,int Y,int W,int H,char *L=0)
    :  Fl_Scroll(X,Y,W,H,L)
    {}

    void make_last_child(Fl_Widget *w)
    {
       bool found_w= false;
       Fl_Widget** a = (Fl_Widget**)array();
       int i,j; for (i = j = 0; j < children(); j++)
          if (a[j] != &hscrollbar && a[j] != &scrollbar && a[j] != w)
              a[i++] = a[j];
          else
              if (a[j] == w)  found_w= true;
       if (found_w)  a[i++] = w;
       a[i++] = &hscrollbar;
       a[i++] = &scrollbar;
    }
};

You then call G_scroll->make_last_child(this) in the FL_PUSH section of 
the handle method of the Box class.

I believe this will solve your issue.

Mike
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to