Hi,
It seems that DND with Flu_Tree_Browser isn't well supported yet. But I have
been able to make it work to some extent. Perhaps someone has insight to share
to help explain some problems i have encountered.
The first step I took to make DND work, was to simply #define USE_FLU_DND in my
program. Now I can drag a leaf of the tree to change its position within a
branch or put it in another branch. However after dragging it to the
destination, and releasing the mouse button, the paste event does not occur
automatically, instead it can be triggered by leaving the program window and
entering it again, or by clicking on a different leaf in the tree. In the
second case, that leaf becomes the grabbed leaf, and is moved instead of the
one which was originally dragged.
I found by trial and error, this annoying behaviour can be avoided, by editing
Flu_Tree_Browser.cpp and simply commenting out a few parts of Flu_Tree_Browser
:: handle. One pattern I have been able to find was that if I comment out the
lines between about 1104 and 1130, between:
if( event == FL_NO_EVENT )//|| event == FL_MOVE )
up to the end of the block beginning with:
if( event == FL_UNFOCUS )
..
then the paste events are processed upon release of the mouse button most of
the time. In particular I find that when the program starts, usually it
behaves with delayed paste as described above initially. But if I open and
close the branches a few times, the paste events begin getting processed upon
release, and continue to do so consistently.
Another thing I don't understand is that if I put :
if(event==FL_RELEASE){
std::cout << "release\n";
}
if(event==FL_DND_RELEASE){
std::cout << "dnd release\n";
}
at the top of the Flu_Tree_Browser :: handle function, when I release the
button during a drag and drop operation, neither FL_RELEASE nor FL_DND_RELEASE
are detected even when the paste operation does occur successfully. I thought
that in the context of DND the paste event is only passed after a
FL_DND_RELEASE event has been passed?
The behaviour I have described above, i have observed using the
Flu_Tree_Browser_Try2 program in the FLU distribution. Also I have been
finding the above behaviour using a slightly simpler test program:
#define USE_FLU_DND
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include "lib/Flu_Tree_Browser.h"
#include "lib/flu_pixmaps.h"
Flu_Tree_Browser *tree;
void init_tree(){
Flu_Tree_Browser::Node* n;
tree->add("blah");
n=tree->last();
n->add("bwah");
n->add("jagsah");
n->add("rabaga");
tree->add("hralabi");
n=tree->last();
n->add("aqww");
n->add("naha");
n->add("baeywa");
}
int main( int argc, char **argv )
{
Fl_Window *win = new Fl_Double_Window( 500, 460, "Flu_Tree_Browser_Try3" );
tree = new Flu_Tree_Browser( 200, 0, 300, 460 );
tree->box( FL_DOWN_BOX );
tree->auto_branches( true );
tree->label( "Tree Browser Demo" );
tree->insertion_mode(FLU_INSERT_BACK);
tree->selection_drag_mode(FLU_DRAG_TO_MOVE);
win->end();
win->resizable( tree );
win->show( argc, argv );
init_tree();
return( Fl::run() );
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk