Hi,
I have been learning how to use Drag and Drop in my own Fl_Widget based widgets 
in FLTK 1.1.7, and I have encountered a problem.  Dragging data from a widget 
in one Fl_Window to a widget in another Fl_Window, works fine as long as when I 
am dragging the mouse across, the cursor does not move over the windows of 
certain other programs.  If the cursor moves over windows for Firefox or Gvim 
for example, my program segfaults.  If the cursor moves over an xterm or xcalc, 
on the other hand, the program works fine.
The operating system i am using is linux (fedora core 2), and the window 
manager is FVWM2.

I notice that the Fl_Input widget does not have this problem, so I guess I must 
be using FLTK incorrectly in programming my widgets to use DND.  I guess i 
could work it out by studying the FLTK source code, but if anyone could give me 
a hint, I would appreciate the time saved.
Below is a program to demonstrate this problem.
Thanks

#include <FL/Fl.h>
#include <FL/Fl_Window.h>
#include <FL/Fl_Widget.h>
#include <FL/fl_draw.h>
#include <iostream>

class sender : public Fl_Widget {
public:
sender(int x,int y,int w,int h):Fl_Widget(x,y,w,h,NULL){}

void draw(void){fl_draw_box((Fl_Boxtype)1,x(),y(),w(),h(),FL_RED);}

int handle(int event){

if(event==FL_PUSH){
Fl::copy("message",7,1);
Fl::dnd();
}
return 1;
}

};

class reciever : public Fl_Widget {
public:
reciever(int x,int y,int w,int h):Fl_Widget(x,y,w,h,NULL){}
void draw(void){ fl_draw_box((Fl_Boxtype)1,x(),y(),w(),h(),FL_GREEN); }
int handle(int event){

if(event==FL_DND_RELEASE){
Fl::paste(*this,1);
std::cout << "text: " << Fl::event_text() << "\n";
}
return 1;
}

};

//drag from red sender to green reciever

int main(void){
Fl_Window a(0,0,200,100);
sender A(0,0,100,100);
a.end();
a.show();
Fl_Window b(0,0,200,100);
reciever B(100,0,100,100);
b.end();
b.show();
Fl::run();
return 1;
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to