Oh, and note I changed the lines that record the x/y event positions
        by subtracting the canvas's x() and y() values.

        The global events returned by Fl::event_x()/y() are relative to the
        upper left corner of the parent /window/. So to get them to be relative
        to the canvas widget (the Fl_Box), you have to subtract off the x() and 
y()
        positions of the canvas.

        So specifically, the code that was changed:

BEFORE:
    case FL_PUSH:
      XC = Fl::event_x();
      YC = Fl::event_y();

AFTER:
    case FL_PUSH:
      XC = Fl::event_x() - x();         // show events relative to canvas's 
coords
      YC = Fl::event_y() - y();         // ""     ""
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to