Author: manolo
Date: 2012-05-16 15:16:56 -0700 (Wed, 16 May 2012)
New Revision: 9509
Log:
Fixed fltk3::event_inside(Rectangle*) and Fl::event_inside(xywh) so they use
widget and event coordinates consistently.
This repairs compatibility with FLTK1 sudoku demo.
Modified:
branches/branch-3.0/include/FL/Fl.H
branches/branch-3.0/src/fltk3/run.cxx
Modified: branches/branch-3.0/include/FL/Fl.H
===================================================================
--- branches/branch-3.0/include/FL/Fl.H 2012-05-16 21:35:08 UTC (rev 9508)
+++ branches/branch-3.0/include/FL/Fl.H 2012-05-16 22:16:56 UTC (rev 9509)
@@ -392,6 +392,10 @@
}
static int event_inside(int x, int y, int w, int h) {
+ if (fltk3::e_widget && !fltk3::e_widget->as_window()) {
+ x -= fltk3::e_widget->dx_window();
+ y -= fltk3::e_widget->dy_window();
+ }
return fltk3::event_inside(x, y, w, h);
}
Modified: branches/branch-3.0/src/fltk3/run.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/run.cxx 2012-05-16 21:35:08 UTC (rev
9508)
+++ branches/branch-3.0/src/fltk3/run.cxx 2012-05-16 22:16:56 UTC (rev
9509)
@@ -216,7 +216,14 @@
\return non-zero, if mouse event is inside the widget
*/
int fltk3::event_inside(const fltk3::Rectangle *r) {
- return r->contains(e_x, e_y);
+ // here r is relative to its enclosing group,
+ // and e_x, e_y are relative to e_widget.
+ int dxr=0, dyr=0;
+ if (((fltk3::Widget*)r)->as_window()) dxr = ((fltk3::Widget*)r)->dx_window();
+ if (((fltk3::Widget*)r)->as_window()) dyr = ((fltk3::Widget*)r)->dy_window();
+ return ((Rectangle*)r)->contains(
+ e_x +
(e_widget->as_window()?0:e_widget->dx_window()) - dxr,
+ e_y +
(e_widget->as_window()?0:e_widget->dy_window()) - dyr);
}
//
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit