Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » draganddrop does not work
draganddrop does not work [message #49776] Mon, 30 April 2018 23:14 Go to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Hi,

I have a class like this
class mainwindow : public DockWindow // public
{
virtual void DragAndDrop(Point p, PasteClip& d);
}

I have an application with docking.
Testing proved that DragAndDrop is not called...
Should it be called looking at examples?
What is the reason?
What would you do ?

Thanks.
Aftershock
Re: draganddrop does not work [message #49777 is a reply to message #49776] Tue, 01 May 2018 09:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Mon, 30 April 2018 23:14
Hi,

I have a class like this
class mainwindow : public DockWindow // public
{
virtual void DragAndDrop(Point p, PasteClip& d);
}

I have an application with docking.
Testing proved that DragAndDrop is not called...
Should it be called looking at examples?
What is the reason?
What would you do ?

Thanks.
Aftershock


Works for me

#include <CtrlLib/CtrlLib.h>
#include <Docking/Docking.h>

using namespace Upp;

struct MyApp : DockWindow {
	virtual void DragAndDrop(Point p, PasteClip& d) {
		if(AcceptFiles(d))
			PromptOK(Join(GetFiles(d), "&"));
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}


Providing testcase and more info (like what is HostOS / compiler) would help....

[Updated on: Tue, 01 May 2018 09:37]

Report message to a moderator

Re: draganddrop does not work [message #49779 is a reply to message #49777] Tue, 01 May 2018 18:52 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Compiler MSC12x64
I also have some docked... that could make a difference?
WithmanualtradeLayout <DockableCtrl> manual_trade;



DockableCtrl & manual_trade_dk = Register ( manual_trade.Title ( t_ ( "Manual trade" ) ) );

DockLeft ( manual_trade_dk );
Re: draganddrop does not work [message #49780 is a reply to message #49779] Wed, 02 May 2018 08:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aftershock wrote on Tue, 01 May 2018 18:52
Compiler MSC12x64


Really? Current U++ does not compile with that.

Quote:

I also have some docked... that could make a difference?
WithmanualtradeLayout <DockableCtrl> manual_trade;



DockableCtrl & manual_trade_dk = Register ( manual_trade.Title ( t_ ( "Manual trade" ) ) );

DockLeft ( manual_trade_dk );


Give me a minimal testcase and I can check. It is really impossible to comment on such little info.
Re: draganddrop does not work [message #49788 is a reply to message #49780] Mon, 07 May 2018 13:21 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
I uploaded an example..

If you drag files where the panel is , it does not work.

Re: draganddrop does not work [message #49789 is a reply to message #49788] Mon, 07 May 2018 13:57 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Hello aftershock,

Your code doesn't work because you need to override the dnd virtual function of the DockableCtrl, not of the DockWindow.

Here is a solution:

main.cpp:

#include <Docking/Docking.h>

using namespace Upp;

#define LAYOUTFILE <tradetester_drag_bug/tradetester.lay>
#include <CtrlCore/lay.h>



class maintradetesterwindow : public DockWindow // public Withtablayout<TopWindow>oin 
{
	public:
	maintradetesterwindow();
	void DragAndDrop(Point p, PasteClip& d);
	class ManualTradeDock : public WithmanualtradeLayout <DockableCtrl> { // <--- 
		virtual void DragAndDrop(Point p, PasteClip& d)
		{
			if(IsDragAndDropSource())
				return;
			if(AcceptFiles(d)) {
			  Vector<String>	files2 = GetFiles(d);
				DUMP(files2);
			}
		}
	};
	ManualTradeDock manual_trade;
};




maintradetesterwindow::maintradetesterwindow()
{

	Sizeable();
	CtrlLayout ( manual_trade );
	DockableCtrl & manual_trade_dk =   Register ( manual_trade.Title ( t_ ( "Manual trade" ) ) );

	DockLeft ( manual_trade_dk );
}

void maintradetesterwindow::DragAndDrop(Point p, PasteClip& d)
{
//	if(IsDragAndDropSource())
//		return;
//	if(AcceptFiles(d)) {
//	  Vector<String>	files2 = GetFiles(d);
///		DUMP(files2);
//	}
}


GUI_APP_MAIN
{
	

	//  ::SColorFace_Write(Black());
	//  ::SColorText_Write(Yellow());



	maintradetesterwindow().Run();
}



It should work now. Smile

Best regards,
Oblivion


[Updated on: Mon, 07 May 2018 14:21]

Report message to a moderator

Re: draganddrop does not work [message #49790 is a reply to message #49789] Mon, 07 May 2018 14:25 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Yes, it worked.
Oblivion , your name shall not be forgotten.


Should not it work on the top of the hierarchy as well?
Re: draganddrop does not work [message #49791 is a reply to message #49790] Mon, 07 May 2018 15:00 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Quote:
Should not it work on the top of the hierarchy as well?


Well, DockWindow is based on TopWindow,and DockableCtrl is based on ParentCtrl. And both of these base classes are based on Ctrl.
CTrl::DragAndDrop() virtual method has an empty default implementation. And it is not overriden in Topwindow or ParentCtrl, which makes sense TBH.

Of course you can redirect the dnd message to the member ctrls in a number of ways.
For example:

class maintradetesterwindow : public DockWindow // public Withtablayout<TopWindow> 
{
	public:
	maintradetesterwindow();
	void DragAndDrop(Point p, PasteClip& d);
	class ManualTradeDock : public WithmanualtradeLayout <DockableCtrl> {
		public:
		virtual void DragAndDrop(Point p, PasteClip& d)
		{
			if(IsDragAndDropSource())
				return;
			if(AcceptFiles(d)) {
			  Vector<String>	files2 = GetFiles(d);
				DUMP(files2);
			}
		}
	};
	ManualTradeDock manual_trade;
};




maintradetesterwindow::maintradetesterwindow()
{

	Sizeable();
	CtrlLayout ( manual_trade );
	DockableCtrl & manual_trade_dk =   Register ( manual_trade.Title ( t_ ( "Manual trade" ) ) );

	DockLeft ( manual_trade_dk );
}

void maintradetesterwindow::DragAndDrop(Point p, PasteClip& d)
{
	manual_trade.DragAndDrop(p, d); // <---
}



But you shouldn't need this for other ctrls, as they already hava their specialized DND methods implemented (e.g. the ArrayCtrl you use).

Best regards,
Oblivion


[Updated on: Mon, 07 May 2018 15:21]

Report message to a moderator

Re: draganddrop does not work [message #49792 is a reply to message #49791] Mon, 07 May 2018 17:06 Go to previous messageGo to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member
Though there is one problem

void maintradetesterwindow::WithdataLayoutEx::DragAndDrop(Point p, PasteClip& d)
{
if(IsDragAndDropSource())
return;
Ctrl* c = GetDragAndDropTarget();
DUMP(c);
if (c!=nullptr)
if (c==&m->datasource_info.analyse)
{
if(AcceptFiles(d)) {
Vector<String> files2 = GetFiles(d);
m->analyse_a_file(files2[0]);
}
}
}
c is always null... I thought I could use to know where files are dropped.

[Updated on: Mon, 07 May 2018 17:06]

Report message to a moderator

Re: draganddrop does not work [message #49793 is a reply to message #49792] Mon, 07 May 2018 17:55 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Quote:
Though there is one problem

void maintradetesterwindow::WithdataLayoutEx::DragAndDrop(Point p, PasteClip& d)
{
if(IsDragAndDropSource())
return;
Ctrl* c = GetDragAndDropTarget();
DUMP(c);
if (c!=nullptr)
if (c==&m->datasource_info.analyse)
{
if(AcceptFiles(d)) {
Vector<String> files2 = GetFiles(d);
m->analyse_a_file(files2[0]);
}
}
}


In general you don't need to manually handle them.
And frankly, I never needed to use GetDragAndDropTarget().
If you need to handle them manually either process the clip according to its data type, or override the given ctrl's DragAndDrop() method. That's it.

Best regards.


[Updated on: Mon, 07 May 2018 18:27]

Report message to a moderator

Previous Topic: StaticText : Add missing GetData/SetData overloads
Next Topic: is there a TerminalCtrl?
Goto Forum:
  


Current Time: Thu Apr 18 14:15:46 CEST 2024

Total time taken to generate the page: 0.01986 seconds