Re: [fltk.general] can't get no FL_DRAG event
thank you. On 04/13/13 14:47, testalucida wrote: can someone explain, what's wrong with this code? There's no FL_DRAG event upcoming in the Box class: The docs for the FL_DRAG event will tell you why: http://fltk.org/doc-1.3/events.html Under the section Mouse Events: FL_DRAG [..] In order to receive FL_DRAG events, the widget must return non-zero when handling FL_PUSH. So add this one line to your handle() method: if (evt == FL_PUSH) rc = 1; Or, just rewrite the handle() method with a switch(), ie: int handle(int evt) { int rc = Fl_Box::handle(evt); switch (evt) { case FL_PUSH: rc=1; break case FL_DRAG: printf(Dragging..\n); rc=1; break; } return rc; } ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
[fltk.general] can't get no FL_DRAG event
Hi all, can someone explain, what's wrong with this code? There's no FL_DRAG event upcoming in the Box class: #include FL/Fl.H #include FL/Fl_Double_Window.H #include FL/Fl_Group.H #include FL/Fl_Box.H #include stdio.h class Box : public Fl_Box { public: Box( int x, int y, int w, int h ) : Fl_Box( x, y, w, h ) { box( FL_UP_BOX ); color( fl_lighter( FL_YELLOW ) ); } protected: int handle( int evt ) { int rc = Fl_Box::handle( evt ); if( evt == FL_DRAG ) { printf( dragging\n, evt ); return 1; } return rc; } }; int main() { Fl_Double_Window *pWin = new Fl_Double_Window( 500, 500, Dragging ); Fl_Group *pGrp = new Fl_Group( 0, 0, 500, 500 ); pGrp-box( FL_FLAT_BOX ); pGrp-color( fl_lighter( FL_GRAY ) ); pGrp-begin(); Box *pBox = new Box( 50, 50, 200, 25 ); pGrp-end(); pWin-end(); pWin-resizable( pWin ); pWin-show(); return Fl::run(); } Thanks bye testalucida ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] can't get no FL_DRAG event
On 04/13/13 14:47, testalucida wrote: can someone explain, what's wrong with this code? There's no FL_DRAG event upcoming in the Box class: The docs for the FL_DRAG event will tell you why: http://fltk.org/doc-1.3/events.html Under the section Mouse Events: FL_DRAG [..] In order to receive FL_DRAG events, the widget must return non-zero when handling FL_PUSH. So add this one line to your handle() method: if (evt == FL_PUSH) rc = 1; Or, just rewrite the handle() method with a switch(), ie: int handle(int evt) { int rc = Fl_Box::handle(evt); switch (evt) { case FL_PUSH: rc=1; break case FL_DRAG: printf(Dragging..\n); rc=1; break; } return rc; } ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk