Greg Ercolano wrote:
> This fixes it for me:
>
> -Fl::copy("message",7,1);
> +Fl::copy("message",7,0);
Your app makes a good simple example of DND.
FLTK doesn't seem to have a good one in its test apps.
I cleaned up a few things in yours, made a few changes to the
event handlers to make sure it worked on all platforms.
Here's the revised code that would probably make a good
DND example for the FLTK test directory.
---- snip
#include <stdio.h>
#include <FL/Fl.h>
#include <FL/Fl_Window.h>
#include <FL/Fl_Box.h>
class Sender : public Fl_Box {
public:
Sender(int x,int y,int w,int h) : Fl_Box(x,y,w,h) {
box(FL_FLAT_BOX); color(9); label("Drag from here");
}
int handle(int event) {
int ret = Fl_Box::handle(event);
switch ( event ) {
case FL_PUSH:
Fl::copy("message",7,0);
Fl::dnd();
return(1);
}
return(ret);
}
};
class Receiver : public Fl_Box {
public:
Receiver(int x,int y,int w,int h) : Fl_Box(x,y,w,h) {
box(FL_FLAT_BOX); color(10); label("to here");
}
int handle(int event) {
int ret = Fl_Box::handle(event);
switch ( event ) {
case FL_DND_ENTER:
case FL_DND_DRAG:
case FL_DND_RELEASE:
return(1);
case FL_PASTE:
label(Fl::event_text());
fprintf(stderr, "PASTE: %s\n", Fl::event_text());
return(1);
}
return(ret);
}
};
//
// Demonstrate DND (drag+drop) from red sender to green receiver
//
int main(int argc, char **argv) {
Fl_Window win_a(0,0,200,100,"Sender");
Sender a(0,0,100,100);
win_a.end();
win_a.show();
Fl_Window win_b(400,0,200,100,"Receiver");
Receiver b(100,0,100,100);
win_b.end();
win_b.show();
return(Fl::run());
}
---- snip
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk