Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Management Window Drag & Drop
Pecan:
--- Quote from: mandrav on February 16, 2006, 05:53:51 pm ---It's because of wxFlatNotebook. It makes its notebooks accept drag'n'drop, effectively killing our drag'n'drop implementation...
--- End quote ---
This wx Drag and Drop problem puts CB between a rock and hard place.
In order to use wxFlatNotebook, it has to give up file DragAndDrop.
The very first SetDropTarget() that wxFNB uses deletes/frees the previous users (CB's)
DropTarget and sends it off to code nervana.
Its a wxWidgets thing. Wx doesn't chain or allow multiple drop targets in
the same window/frame. That leaves the last guy who used SetDropTarget() to
not only support his own drop format, but all those used previous to him.
Not good..
There is a way around this I think. Since wxFNB is using wxMouseEvents to
drive DragAndDrop, CB could use the same. With a few coding guidelines the
two could "chain" SetDropTarget() via mouse events and event.Skip().
Guidelines would be as follows:
Use your choice of mouse event to drive DragAndDrop
If the drop area isn't yours, pass it on with event.Skip()
Dont assume your drop target exists just because it was previous allocated,
allocate it anew each entry.
Set up data for your DragAndDrop formats
SetDropTarget to your window/frame
Execute the DoDragDrop
Pass on the event anyway with event.Skip()
Return;
A rough example would be:
myOnMouseMove(event wxMouseEvent)
If (not (HitTest()==my area of interest)) {event.Skip; return; }
// dont assume DropTarget still exists
myWindow* thisEvent = (myWindow*)event.GetEventObject();
if (myWindow.GetDropTarget() == 0) m_pMyDropTarget = new myDropTargetClass(thisEvent....)
wxDragInfo draginfo(this, ...);
wxDataObject dataobject(...);
dataobject.SetData(sizeof(dragInfo), &draginfo);
wxDropSource dragSource(this);
dragSource.SetData(dataobject);
SetDropTarget(m_pMyDropTarget);
dragSource.DoDragDrop(...);
event.Skip()
return
If you'd like, I could take a stab at patching and testing this idea.
thanks
pecan
mandrav:
--- Quote ---If you'd like, I could take a stab at patching and testing this idea.
--- End quote ---
Be my guest :)
The other solution is to remove drag'n'drop support from wxFNB...
takeshimiya:
Pecan: That would be great.
Do you have any idea if it's possible doing the same but for wxScintilla?
Pecan:
--- Quote from: Takeshi Miya on February 17, 2006, 03:10:02 pm ---Pecan: That would be great.
Do you have any idea if it's possible doing the same but for wxScintilla?
--- End quote ---
Thanks for the reminder. I'll take a look at that...
thanks
pecan
Pecan:
--- Quote from: mandrav on February 16, 2006, 05:53:51 pm ---It's because of wxFlatNotebook. It makes its notebooks accept drag'n'drop, effectively killing our drag'n'drop implementation...
--- End quote ---
February 18, 2006 8:21 AM
The code gnomes are yet bent-in-half laughing at me…
My idea to use mouse events to implement SetDropTarget() will not work when the drop source originates outside of the CB main frame because the operating system hides the mouse interrupts (events) until after the mouse key is lifted.
But (there’s always a big butt…) that doesn’t stop us from fixing the problem.
While inserting my favorite asm(“int3”) in the wxFNB code I realized that, at least for CB, wxFNB is not using its “wxFlatNotebook::DropTarget”; its using a “wxPageContainer::DropTarget” to drag tabs around.
So the simplest solution is to steal back the “main::DropTarget” after instantiating wxFlatNnotebooks. So at main.cpp line 549 insert the following:
--- Code: --- // wxFlatNotebooks are allocated by the Manager::Get() calls above. //pecan 2/18/2006
// wxFlatNotebooks isn't using the wxFlatNnotebook drop target for //pecan 2/18/2006
// CodeBlocks even though it sets them. It uses the wxPageContainer //pecan 2/18/2006
// drop target to drag tabs around. So here we steal back our Drag'n'Drop //pecan 2/18/2006
// targets in order to drop files into the project and files manager. //pecan 2/18/2006
m_pEdMan->GetNotebook()->SetDropTarget(new wxMyFileDropTarget(this)); //pecan 2/18/2006
m_pPrjMan->GetNotebook()->SetDropTarget(new wxMyFileDropTarget(this)); //pecan 2/18/2006
m_pMsgMan->GetNotebook()->SetDropTarget(new wxMyFileDropTarget(this)); //pecan 2/18/2006
--- End code ---
patch has been submitted
thanks
pecan
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version