Skip to content

Commit d30d194

Browse files
committed
Merge pull request livecode#3054 from runrevmark/widget-bypass_dnd
[[ Widgets ]] Bypass widgets for drag-drop related messages.
2 parents 2cbead5 + 0fefe76 commit d30d194

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

engine/src/card.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,14 @@ Boolean MCCard::mfocus(int2 x, int2 y)
589589
mfocused = tptr;
590590

591591
// The widget event manager handles enter/leave itself
592-
if (newfocused && mfocused != NULL
593-
&& mfocused -> getref() -> gettype() != CT_GROUP
594-
&& mfocused -> getref() -> gettype() != CT_WIDGET)
592+
if (newfocused && mfocused != NULL &&
593+
mfocused -> getref() -> gettype() != CT_GROUP &&
594+
#ifdef WIDGETS_HANDLE_DND
595+
mfocused -> getref() -> gettype() != CT_WIDGET)
596+
#else
597+
(MCdispatcher -> isdragtarget() ||
598+
mfocused -> getref() -> gettype() != CT_WIDGET))
599+
#endif
595600
{
596601
mfocused->getref()->enter();
597602

engine/src/dispatch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,9 +2219,12 @@ void MCDispatch::dodrop(bool p_source)
22192219
{
22202220
// We are only the source
22212221
m_drag_end_sent = true;
2222+
2223+
#ifdef WIDGETS_HANDLE_DND
22222224
if (MCdragsource->gettype() == CT_WIDGET)
22232225
MCwidgeteventmanager->event_dnd_end(reinterpret_cast<MCWidget*>(MCdragsource));
22242226
else
2227+
#endif
22252228
MCdragsource -> message(MCM_drag_end);
22262229

22272230
// OK-2008-10-21 : [[Bug 7316]] - Cursor in script editor follows mouse after dragging to non-LiveCode target.
@@ -2342,12 +2345,14 @@ void MCDispatch::dodrop(bool p_source)
23422345
t_auto_drop = MCdragdest != NULL;
23432346
if (t_auto_drop)
23442347
{
2348+
#ifdef WIDGETS_HANDLE_DND
23452349
if (MCdragdest->gettype() == CT_WIDGET)
23462350
{
23472351
MCwidgeteventmanager->event_dnd_drop(reinterpret_cast<MCWidget*>(MCdragdest));
23482352
t_auto_drop = false;
23492353
}
23502354
else
2355+
#endif
23512356
{
23522357
t_auto_drop = MCdragdest -> message(MCM_drag_drop) != ES_NORMAL;
23532358
}
@@ -2392,12 +2397,14 @@ void MCDispatch::dodrop(bool p_source)
23922397
if (MCdragsource != NULL)
23932398
{
23942399
m_drag_end_sent = true;
2400+
#ifdef WIDGETS_HANDLE_DND
23952401
if (MCdragsource->gettype() == CT_WIDGET)
23962402
{
23972403
MCwidgeteventmanager->event_dnd_end(reinterpret_cast<MCWidget*>(MCdragsource));
23982404
t_auto_end = false;
23992405
}
24002406
else
2407+
#endif
24012408
{
24022409
t_auto_end = MCdragsource -> message(MCM_drag_end) != ES_NORMAL;
24032410
}

engine/src/widget.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ Boolean MCWidget::mfocus(int2 p_x, int2 p_y)
276276
(getflag(F_DISABLED) && (getstack() -> gettool(this) == T_BROWSE)))
277277
return False;
278278

279-
if (getstack() -> gettool(this) != T_BROWSE)
279+
if (getstack() -> gettool(this) != T_BROWSE ||
280+
#ifdef WIDGETS_HANDLE_DND
281+
false)
282+
#else
283+
MCdispatcher -> isdragtarget())
284+
#endif
280285
return MCControl::mfocus(p_x, p_y);
281286

282287
// Update the mouse loc.
@@ -291,7 +296,12 @@ Boolean MCWidget::mfocus(int2 p_x, int2 p_y)
291296

292297
void MCWidget::munfocus(void)
293298
{
294-
if (getstack() -> gettool(this) != T_BROWSE)
299+
if (getstack() -> gettool(this) != T_BROWSE ||
300+
#ifdef WIDGETS_HANDLE_DND
301+
false)
302+
#else
303+
MCdispatcher -> isdragtarget())
304+
#endif
295305
{
296306
MCControl::munfocus();
297307
return;

0 commit comments

Comments
 (0)