matthiasm wrote:
>Do you think you can minimize your code to a single
>page or so that I can compile and run on my machine?
Thanks for your help.
Here's the code extremely minimized.
Actually it's just a dragable box but the pb remains the same.
You'll notice that when the right button is pressed while draging
nothing happens, you just can keep drag the box. But when it's
released draging stops.
Anyway, I'd like to know how to completely skip the right mouse button events
in order it doesn't disturb the stream of the other events.
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Group.H>
class Toolbar : public Fl_Group
{
int handle(int e);
int xOffPos, yOffPos, dx, dy; //offsets
public:
Toolbar(int x, int y, int w, int h, const char *l = 0):Fl_Group(x, y, w, h,
l)
{
color((Fl_Color) FL_GRAY);
box(FL_UP_BOX);
}
};
int Toolbar::handle(int e)
{
static int xoff = 0, yoff = 0;
switch(e)
{
case FL_PUSH:
if(Fl::event_button() == FL_LEFT_MOUSE) //set the offsets
{
xoff = x() - Fl::event_x_root();
yoff = y() - Fl::event_y_root();
}
return 1;
case FL_RELEASE:
return 1;
case FL_DRAG:
if((Fl::event_state()&FL_BUTTON1) == FL_BUTTON1)
{
position(xoff + Fl::event_x_root(),
yoff + Fl::event_y_root());
xOffPos = xoff + Fl::event_x_root();
yOffPos = yoff + Fl::event_y_root();
parent()->redraw();
}
return 1;
default:
return Fl_Group::handle(e);
}
return Fl_Group::handle(e);
}
class Application : public Fl_Double_Window
{
Toolbar *toolbar;
public:
Application(int w, int h, const char *l, int argc, char *argv[]);
};
Application::Application(int w, int h, const char *l, int argc, char *argv[])
: Fl_Double_Window(w, h, l)
{
box(FL_DOWN_BOX);
color((Fl_Color) FL_WHITE);
toolbar = new Toolbar(10,10,200, 50);
resizable(this);
show(argc, argv);
}
int main (int argc, char **argv)
{
Application myApp(500, 300, "Mouse Event Pb", argc, argv);
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk