PDA

View Full Version : onDrop question



Bidmaron
April 18th, 2009, 14:23
As I'm continuing to delve into making extensions, I'm running across some weird behavior that I don't understand.

Specifically, I put a print debugging statement in the onDrop event, and when I drop something on my control, I am getting "dropping" printed out in the console twice rather than the once you'd expect.

I am working on 3.5jpg in the Items handling area, and here is the xml from the two controls where I am trying to drop items:


<subwindow name="stats">
<bounds>22,64,-35,-23</bounds>
<class>item_stats</class>
<script file="item_drop.lua" />
</subwindow>
...
<subwindow name="description">
<bounds>22,64,-35,-23</bounds>
<class>item_description</class>
<script file="item_drop.lua" />
</subwindow>

Here is the code in item_drop.lua:

function onDrop()
print "dropping";
end

What am I missing here?

Moon Wizard
April 18th, 2009, 21:37
You need to make sure that you return a "true" value when the onDrop function is called that you want to capture the drop event. Otherwise, the drop event will continue to cascade to any windows below.



function onDrop(button, x, y, dragdata)
-- If number, then capture the drop event
if dragdata.isType("number") then
print "dropped number";
return true;
end

-- Otherwise just let the event fall-through
end


Cheers,
JPG

Bidmaron
April 19th, 2009, 16:49
Thanks, Moon_wizard