[fltk/fltk] Fl::event_x() & event_y() doesn't take into account embedded window's coords with Mouse wheel events (#210)
Mohammed Alyousef
Apr 06, 2021
Hello
Sorry for the weakly descriptive title.
Given the following program:
#include<FL/Enumerations.H>
#include<FL/Fl.H>
#include<FL/Fl_Window.H>// #include <FL/Fl_Group.H>structEmbed : publicFl_Window {
Embed(int x, int y, int w, int h, constchar *title = 0)
: Fl_Window(x, y, w, h, title) {}
inthandle(int e) {
switch (e) {
case FL_PUSH:
printf("%d, %d\n", Fl::event_x(), Fl::event_y());
fflush(stdout);
break;
case FL_MOUSEWHEEL:
printf("%d, %d\n", Fl::event_x(), Fl::event_y());
fflush(stdout);
break;
}
returnFl_Window::handle(e);
}
};
intmain() {
Fl_Window win(100, 100, 400, 300);
Embed embed(0, 0, 400, 300);
win.end();
win.show();
win.redraw();
returnFl::run();
}
For an embedded window, the values retrieved from Fl::event_x() and Fl::event_y() differ depending on the event. If we change Embed to derive from Fl_Group, then the values are correct. Also the values of Fl::event_x_root() and Fl::event_y_root() are correct.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.