|
|
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 |
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 |
|
mirek
Messages: 14038 Registered: November 2005
|
Ultimate Member |
|
|
aftershock wrote on Mon, 30 April 2018 23:14Hi,
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 #49789 is a reply to message #49788] |
Mon, 07 May 2018 13:57 |
Oblivion
Messages: 1112 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.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 07 May 2018 14:21] Report message to a moderator
|
|
|
|
Re: draganddrop does not work [message #49791 is a reply to message #49790] |
Mon, 07 May 2018 15:00 |
Oblivion
Messages: 1112 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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[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 |
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
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 08:23:38 CEST 2024
Total time taken to generate the page: 0.02584 seconds
|
|
|