Fix drag & drop management.

[GB.GTK]
* BUG: Fix drag & drop management.

[GB.GTK3]
* BUG: Fix drag & drop management.
This commit is contained in:
Benoît Minisini 2022-09-02 02:29:49 +02:00
parent 969b7495e0
commit 4183b21ddd
5 changed files with 36 additions and 17 deletions

View file

@ -244,8 +244,8 @@ bool CB_control_drag(gControl *sender)
{
CWIDGET *_object = GetObject(sender);
if (!THIS)
return true;
/*if (!THIS)
return true;*/
if (!GB.CanRaise(THIS, EVENT_Drag))
{

View file

@ -1531,6 +1531,14 @@ Drag & Drop
**********************************************************************/
bool gControl::acceptDrops() const
{
if (_proxy)
return _proxy->acceptDrops();
else
return _accept_drops;
}
void gControl::setAcceptDrops(bool vl)
{
GtkWidget *w;

View file

@ -113,7 +113,7 @@ public:
void setExpand (bool vl);
void setIgnore (bool vl);
bool acceptDrops() const { return _accept_drops; }
bool acceptDrops() const;
void setAcceptDrops(bool vl);
const char *name() const { return _name; }

View file

@ -787,8 +787,10 @@ bool gDrag::setCurrent(gControl *control)
{
gControl *current;
//fprintf(stderr, "gDrag::setCurrent: %s -> %s\n", _current ? _current->name() : "NULL", control ? control->name() : "NULL");
if (_current == control)
return true;
return false;
if (_current)
{

View file

@ -176,7 +176,7 @@ static void cb_drag_leave(GtkWidget *widget, GdkDragContext *context, guint time
static gboolean cb_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gControl *data)
{
bool retval = true;
bool cancel;
GdkModifierType mask;
GdkDragAction dnd_action;
@ -230,9 +230,12 @@ static gboolean cb_drag_motion(GtkWidget *widget, GdkDragContext *context, gint
context = gDrag::enable(context, data, time);
retval = gDrag::setCurrent(data);
if (retval)
cancel = gDrag::setCurrent(data);
#if DEBUG_DND
fprintf(stderr, "setCurrent -> %d\n", cancel);
#endif
if (!cancel)
{
//fprintf(stderr, "cb_drag_motion: onDragMove: %p\n", widget);
gControl *control = data;
@ -247,8 +250,8 @@ static gboolean cb_drag_motion(GtkWidget *widget, GdkDragContext *context, gint
#endif
if (CB_control_can_raise(control, gEvent_DragMove))
{
retval = !CB_control_drag_move(control);
if (!retval)
cancel = CB_control_drag_move(control);
if (cancel)
break;
}
control = control->_proxy_for;
@ -257,7 +260,14 @@ static gboolean cb_drag_motion(GtkWidget *widget, GdkDragContext *context, gint
context = gDrag::disable(context);
if (retval)
if (cancel)
{
#if DEBUG_DND
fprintf(stderr, "cb_drag_motion: cancel\n");
#endif
gDrag::hide(data);
}
else
{
#if DEBUG_DND
fprintf(stderr, "cb_drag_motion: accept %d / %d\n", action, gdk_drag_context_get_selected_action(context));
@ -266,10 +276,6 @@ static gboolean cb_drag_motion(GtkWidget *widget, GdkDragContext *context, gint
return true;
}
#if DEBUG_DND
fprintf(stderr, "cb_drag_motion: cancel\n");
#endif
gDrag::hide(data);
return false;
}
@ -288,11 +294,14 @@ static gboolean cb_drag_drop(GtkWidget *widget, GdkDragContext *context, gint x,
// cb_drag_leave() is automatically called when a drop occurs
//cb_drag_leave(widget, context, time, data);
if (!CB_control_can_raise(data, gEvent_Drop))
/*if (!data->_accept_drops) //acceptDrops())
return false;*/
/*if (!CB_control_can_raise(data, gEvent_Drop))
{
gtk_drag_finish(context, false, false, time);
return false;
}
}*/
source = gApplication::controlItem(gtk_drag_get_source_widget(context));