FLTK logo

[fltk/fltk] Fl::event_x() & event_y() doesn't take into account embedded window's coords with Mouse wheel events (#210)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

[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>

struct Embed : public Fl_Window {
  Embed(int x, int y, int w, int h, const char *title = 0)
      : Fl_Window(x, y, w, h, title) {}

  int handle(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;
    }
    return Fl_Window::handle(e);
  }
};

int main() {
  Fl_Window win(100, 100, 400, 300);
  Embed embed(0, 0, 400, 300);
  win.end();
  win.show();
  win.redraw();
  return Fl::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.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.