Bug Encountered with DMC_DragDrop Plugin

Oi Community, 

I’ve hit a wall I’ve been trying to climb over for about a week now.

Here’s the short version of the story:

I can run playGame.lua wonderfully the first time, global variables pass to the right locations, and life is grand. When I attempt to navigate back to the playGame.lua scene everything loads correctly but when I attempt a drag any of the three drag items, that worked before, I receive this Runtime error and I can not pin down the problem.

I’ve examined line 415 in dmc_dragdrop.lua (I’ve added a few edit to it): 

local isWithinBounds = bounds.xMin \<= x and bounds.xMax \>= x and bounds.yMin \<= 245 and bounds.yMax \>= 415

----Error-----

2013-08-13 10:40:00.525 Corona Simulator[375:707] Runtime error

…e/Desktop/MEplusYOU/KillFriendMarry/dmc_dragdrop.lua:415: attempt to index upvalue ‘bounds’ (a nil value)

stack traceback:

    [C]: ?

    …e/Desktop/MEplusYOU/KillFriendMarry/dmc_dragdrop.lua:415: in function ‘_searchDropTargets’

    …e/Desktop/MEplusYOU/KillFriendMarry/dmc_dragdrop.lua:248: in function <…e/Desktop/MEplusYOU/KillFriendMarry/dmc_dragdrop.lua:232>

    ?: in function <?:218>


I’m trying trying to understand why this error is occurring and how I can fix it so when the page is loaded again, I can drag/drop and keep doing so without a runtime error. 

playGame.lua

module(..., package.seeall) local director = require("director") function new() local playGame = display.newGroup() \_G.DragMgr = nil

        _G.Utils = nil

        _G.DropTarget = nil

        _G.DragMgr = require ( “dmc_dragdrop” )

        _G.Utils = require( “dmc_utils” )

        _G.DropTarget = require ( “drop_target” )

    

        _G.currentTouch = “”

        _G.blockAssignment = {“block”, “block”, “block” }

        

        _G.killPair = false

     _G.friendPair = false

     _G.marryPair = false

        

        _G.kill = nil

        _G.friend = nil

        _G.marry =  nil

   

        _G.dropTarget = {nil, nil, nil}

        _G.brand = {nil, nil, nil}

local holder = 0 --Title BACKGROUND _G.bgPlayGame = display.newImageRect(“KFM/background2.jpg”, 640, 960) _G.bgPlayGame.x = display.contentWidth / 2 _G.bgPlayGame.y = display.contentHeight / 2 local function createSquare(size, name) s = display.newImageRect(“KFM/”…name…".png", 170, 177) return s end --Smaller logo (note: the placement will need to be lower to see the logo _G.small_logo = display.newImageRect(“KFM/titleBanner.png”, 640, 127) _G.small_logo.x = display.contentWidth / 2 _G.small_logo.y = 60 local function brandRoulette() --brand random function holder = math.random(2) if holder == 1 then --Shoes _G.numberHolder[1] = 1 _G.numberHolder[2] = 2 _G.numberHolder[3] = 3 elseif holder == 2 then --Fast Food _G.numberHolder[1] = 4 _G.numberHolder[2] = 5 _G.numberHolder[3] = 6 end end brandRoulette() --brand roulette(will eventually be an array function) _G.brand[1] = display.newImageRect(“KFM/”…_G.brandIcon[_G.numberHolder[1]]…".png", 130, 130) _G.brand[1].x = 115 _G.brand[1].y = 330 _G.brand[2] = display.newImageRect(“KFM/”…_G.brandIcon[_G.numberHolder[2]]…".png", 130, 130) _G.brand[2].x = 320 --somewhere close to 320px of brand placement #2 _G.brand[2].y = 330 _G.brand[3] = display.newImageRect(“KFM/”…_G.brandIcon[_G.numberHolder[3]]…".png", 130, 130) _G.brand[3].x = 526 --somewhere close to 320px of brand placement #3 _G.brand[3].y = 330 function changingBlocks( ) if _G.currentTouch == “” then --Grey blocks _G.block[1] = display.newImageRect(“KFM/”…_G.blockAssignment[1]…".png", 195, 194) _G.block[1].x = 115 --somewhere close to 100px of brand placement #1 _G.block[1].y = 330 _G.block[2] = display.newImageRect(“KFM/”…_G.blockAssignment[2]…".png", 195, 194) _G.block[2].x = 320 --somewhere close to 100px of brand placement #1 _G.block[2].y = 330 _G.block[3] = display.newImageRect(“KFM/”…_G.blockAssignment[3]…".png", 195, 194) _G.block[3].x = 525 --somewhere close to 100px of brand placement #1 _G.block[3].y = 330 elseif _G.currentTouch == “kill” then if _G.targetX == 115 then --block1 _G.blockAssignment[1] = (“glow_”…_G.currentTouch) _G.block[1]:removeSelf() _G.block[1] = display.newImageRect(“KFM/”…_G.blockAssignment[1]…".png", 195, 194) _G.block[1].x = 115 --somewhere close to 100px of brand placement #1 _G.block[1].y = 330 elseif _G.targetX == 320 then --block2 _G.blockAssignment[2] = (“glow_”…_G.currentTouch) _G.block[2]:removeSelf() _G.block[2] = display.newImageRect(“KFM/”…_G.blockAssignment[2]…".png", 195, 194) _G.block[2].x = 320 --somewhere close to 100px of brand placement #1 _G.block[2].y = 330 elseif _G.targetX == 526 then --block3 _G.blockAssignment[3] = (“glow_”…_G.currentTouch) _G.block[3]:removeSelf() _G.block[3] = display.newImageRect(“KFM/”…_G.blockAssignment[3]…".png", 195, 194) _G.block[3].x = 526 --somewhere close to 100px of brand placement #1 _G.block[3].y = 330 end elseif _G.currentTouch == “friend” then if _G.targetX == 115 then --block1 _G.blockAssignment[1] = (“glow_”…_G.currentTouch) _G.block[1]:removeSelf() _G.block[1] = display.newImageRect(“KFM/”…_G.blockAssignment[1]…".png", 195, 194) _G.block[1].x = 115 --somewhere close to 100px of brand placement #1 _G.block[1].y = 330 elseif _G.targetX == 320 then --block2 _G.blockAssignment[2] = (“glow_”…_G.currentTouch) _G.block[2]:removeSelf() _G.block[2] = display.newImageRect(“KFM/”…_G.blockAssignment[2]…".png", 195, 194) _G.block[2].x = 320 --somewhere close to 100px of brand placement #1 _G.block[2].y = 330 elseif _G.targetX == 526 then --block3 _G.blockAssignment[3] = (“glow_”…_G.currentTouch) _G.block[3]:removeSelf() _G.block[3] = display.newImageRect(“KFM/”…_G.blockAssignment[3]…".png", 195, 194) _G.block[3].x = 526 --somewhere close to 100px of brand placement #1 _G.block[3].y = 330 end elseif _G.currentTouch == “marry” then if _G.targetX == 115 then --block1 _G.blockAssignment[1] = (“glow_”…_G.currentTouch) _G.block[1]:removeSelf() _G.block[1] = display.newImageRect(“KFM/”…_G.blockAssignment[1]…".png", 195, 194) _G.block[1].x = 115 --somewhere close to 100px of brand placement #1 _G.block[1].y = 330 elseif _G.targetX == 320 then --block2 _G.blockAssignment[2] = (“glow_”…_G.currentTouch) _G.block[2]:removeSelf() _G.block[2] = display.newImageRect(“KFM/”…_G.blockAssignment[2]…".png", 195, 194) _G.block[2].x = 320 --somewhere close to 100px of brand placement #1 _G.block[2].y = 330 elseif _G.targetX == 526 then --block3 _G.blockAssignment[3] = (“glow_”…_G.currentTouch) _G.block[3]:removeSelf() _G.block[3] = display.newImageRect(“KFM/”…_G.blockAssignment[3]…".png", 195, 194) _G.block[3].x = 526 --somewhere close to 100px of brand placement #1 _G.block[3].y = 330 end end playGame:insert(2, _G.block[1]) playGame:insert(2, _G.block[2]) playGame:insert(2, _G.block[3]) end _G.dropTarget[1] = DropTarget.create( { format={ “kill”, “friend”, “marry” } } ) _G.dropTarget[1].x = 115 _G.dropTarget[1].y = 330 DragMgr:register( _G.dropTarget[1] ) _G.dropTarget[2] = DropTarget.create( { format={ “kill”, “friend”, “marry” } } ) _G.dropTarget[2].x = 320 _G.dropTarget[2].y = 330 DragMgr:register( _G.dropTarget[2] ) _G.dropTarget[3] = DropTarget.create( { format={ “kill”, “friend”, “marry” } } ) _G.dropTarget[3].x = 526 _G.dropTarget[3].y = 330 DragMgr:register( _G.dropTarget[3] ) --Kill _G.kill = display.newImageRect(“KFM/kill.png”, 170, 177) _G.kill.x = 100 _G.kill.y = 640 function _G.kill:touch(event) if event.phase == “began” then if _G.killPair == false and _G.firstRound ~= 0 then local target = event.target _G.currentTouch = “kill” – setup info about the drag operation local drag_infoKill = { proxy = createSquare( { 175, 175 }, _G.idKill), format = “kill”, yOffset = -30, } – now tell the Drag Manager about it DragMgr:doDrag( target, event, drag_infoKill ) end end return true end if _G.killPair == false then _G.kill:addEventListener(“touch”, _G.kill) end --Friend _G.friend = display.newImageRect(“KFM/friend.png”, 170, 177) _G.friend.x = 320 _G.friend.y = 640 function _G.friend:touch(event) if event.phase == “began” then if _G.friendPair == false and _G.firstRound ~= 0 then local target = event.target _G.currentTouch = “friend” – setup info about the drag operation local drag_info = { proxy = createSquare( { 175, 175 }, _G.idFriend), format = “friend”, yOffset = -30, } – now tell the Drag Manager about it DragMgr:doDrag( target, event, drag_info ) end end return true end if _G.friendPair == false then _G.friend:addEventListener(“touch”, _G.friend) end --Marry _G.marry = display.newImageRect(“KFM/marry.png”, 170, 177) _G.marry.x = 540 _G.marry.y = 640 function _G.marry:touch(event) if event.phase == “began” then if _G.marryPair == false and _G.firstRound ~= 0 then local target = event.target _G.currentTouch = “marry” – setup info about the drag operation local drag_info = { proxy = createSquare( { 175, 175 }, _G.idMarry), format = “marry”, yOffset = -30, } – now tell the Drag Manager about it DragMgr:doDrag( target, event, drag_info ) end end return true end if _G.marryPair == false then _G.marry:addEventListener(“touch”, _G.marry) end --commit button _G.commit_button = display.newImageRect(“KFM/commit_button.png”, 253, 40) _G.commit_button:setReferencePoint( display.CenterReferencePoint ) _G.commit_button.x = display.contentWidth / 2 _G.commit_button.y = 820 local function changeScene( event ) if _G.blockAssignment[3] ~= “block” and _G.blockAssignment[2] ~= “block” and _G.blockAssignment[1] ~= “block” then if event.phase == “ended” then --call pop up director:changeScene(“results”, “crossfade”) end end end _G.commit_button:addEventListener(“touch”, changeScene) --NAV MENU _G.aboutNav = display.newImageRect(“KFM/about_up.png”, 137, 81) _G.aboutNav.x = 100 _G.aboutNav.y = 915 local function changeScene( event ) if event.phase == “ended” then director:changeScene(“about”) end end _G.aboutNav:addEventListener(“touch”, changeScene) _G.playNav = display.newImageRect(“KFM/play_down.png”, 137, 81) _G.playNav.x = 330 _G.playNav.y = 915 _G.profileNav = display.newImageRect(“KFM/profile_up.png”, 137, 81) _G.profileNav.x = 545 _G.profileNav.y = 915 local function changeScene( event ) if event.phase == “ended” then director:changeScene(“profile”) end end _G.profileNav:addEventListener(“touch”, changeScene) local bgOverlay = display.newImageRect(“KFM/overlay.png”, 640, 960) bgOverlay.x = display.contentWidth / 2 bgOverlay.y = display.contentHeight / 2 local instructions = display.newImageRect(“KFM/alert.png”, 560, 178) instructions.x = display.contentWidth / 2 instructions.y = display.contentHeight / 2 if _G.firstRound == 1 then instructions.alpha = 0.0 bgOverlay.alpha = 0.0 end local function disappearInstructions ( event ) _G.firstRound = 1 transition.to( instructions, {time=1000, alpha=0.0}) transition.to( bgOverlay, {time=1000, alpha=0.0}) end instructions:addEventListener(“touch”, disappearInstructions) – all objects must be added to group playGame:insert(_G.bgPlayGame ) playGame:insert(_G.small_logo) playGame:insert(_G.brand[1]) playGame:insert(_G.brand[2]) playGame:insert(_G.brand[3]) playGame:insert(_G.kill) playGame:insert(_G.friend) playGame:insert(_G.marry) playGame:insert(bgOverlay) playGame:insert(instructions) playGame:insert(_G.commit_button) playGame:insert(2, _G.aboutNav) playGame:insert(2, _G.playNav) playGame:insert(2, _G.profileNav) changingBlocks() return playGame end

DMC DragDrop Library

https://github.com/dmccuskey/DMC-Corona-Library

My copy with edits.

--====================================================================-- -- dmc\_dragdrop.lua -- -- by David McCuskey -- Documentation: http://docs.davidmccuskey.com/display/docs/dmc\_dragdrop.lua --====================================================================-- --[[Copyright (C) 2011-2013 David McCuskey. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]] -- ========================================================= -- Imports -- ========================================================= -- import DMC Objects file local Objects = require( "dmc\_objects" ) local PlayGame = require ( "playGame") -- setup some aliases to make code cleaner local inheritsFrom = Objects.inheritsFrom local Object = Objects.Object local coronaMetaTable = getmetatable( display.getCurrentStage() ) --- Returns true for any object returned from display.new\*(). -- note that all Corona types seem to share the same metatable... local isDisplayObject = function( object ) return type( object ) == "table" and getmetatable( object ) == coronaMetaTable end -- createSquare() -- -- function to help create shapes, useful for drag/drop target examples -- local function createSquare( size, color ) s = display.newRect(0, 0, unpack( size ) ) s.strokeWidth = 3 s:setFillColor( 0, 255, 0) return s end --====================================================================-- -- Drag Drop class --====================================================================-- local DragDrop = inheritsFrom( Object ) DragDrop.NAME = "Drag Drop" DragDrop.\_registered = {} -- hash of all registered objects DragDrop.\_onDragStart = {} -- list of registered objects with dragStart() DragDrop.\_onDragStop = {} -- list of registered objects with dragStop() -- property name holding Corona display object DragDrop.DISPLAY\_PROPERTY = "display" DragDrop.ANIMATE\_TIME\_SLOW = 300 DragDrop.ANIMATE\_TIME\_FAST = 100 -- Drag Targets Info -- a hash, indexed by drag target source DragDrop.\_drag\_targets = {} -- Drop Target Info -- drop\_target: object being dropped on, Display Object -- drop\_target: dropped point is selected, Boolean DragDrop.drop\_target = nil DragDrop.drop\_target\_accept = false function DragDrop:setDisplayProperty( name ) self.DISPLAY\_PROPERTY = name end function DragDrop:register( obj, params ) -- create our storage data structure for the object local ds = {} ds.obj = obj ds.call\_with\_object = false -- whether we call using object if not params then ds.call\_with\_object = true t = obj else ds.call\_with\_object = false t = params end ds.dragStart = t.dragStart or nil ds.dragEnter = t.dragEnter or nil ds.dragOver = t.dragOver or nil ds.dragDrop = t.dragDrop or nil ds.dragExit = t.dragExit or nil ds.dragStop = t.dragStop or nil self.\_registered[obj] = ds -- save for lookup optimization if ds.dragStart then table.insert( self.\_onDragStart, obj ) end if ds.dragStop then table.insert( self.\_onDragStop, obj ) end end function DragDrop:doDrag( drag\_orgin, event, drag\_op\_info ) --== process Drag Target Info params local drag\_op\_info = drag\_op\_info or {} local size = { drag\_orgin.width, drag\_orgin.height } local drag\_proxy = drag\_op\_info.proxy or createSquare( size, { 200, 200, 200 } ); local drag\_info = {} drag\_info.proxy = drag\_proxy drag\_info.origin = drag\_orgin drag\_info.format = drag\_op\_info.format drag\_info.data = drag\_op\_info.data drag\_info.x\_offset = drag\_op\_info.xOffset or 0 drag\_info.y\_offset = drag\_op\_info.yOffset or 0 drag\_info.alpha = drag\_op\_info.alpha or 0.5 DragDrop.\_drag\_targets[drag\_proxy] = drag\_info --== Update the Drag Target visual item drag\_proxy.x = event.x + drag\_info.x\_offset drag\_proxy.y = event.y + drag\_info.y\_offset --drag\_proxy.alpha = drag\_info.alpha --== Start our drag operation drag\_proxy.\_\_is\_dmc\_drag = true display.getCurrentStage():setFocus( drag\_proxy ) self:\_doDragStart( drag\_proxy ) self:\_startListening( drag\_proxy ) end function DragDrop:\_createEventStructure( obj, drag\_info ) local drag\_info = drag\_info or {} local e = { target = obj, format = drag\_info.format, data = drag\_info.data, } return e end function DragDrop:\_doDragStart( drag\_proxy ) local drag\_info = DragDrop.\_drag\_targets[drag\_proxy] local dragList = self.\_onDragStart for i=1, #dragList do local o = dragList[i] local ds = self.\_registered[o] local f = ds.dragStart local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then f( o, e ) else f( e ) end end end function DragDrop:\_doDragStop( drag\_proxy ) local drag\_info = DragDrop.\_drag\_targets[drag\_proxy] local dragList = self.\_onDragStop for i=1, #dragList do local o = dragList[i] local ds = self.\_registered[o] local f = ds.dragStop local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then f( o, e ) else f( e ) end end end function DragDrop:acceptDragDrop() DragDrop.drop\_target\_accept = true end function DragDrop:touch( e ) local proxy = e.target local phase = e.phase local result = false local drag\_info = DragDrop.\_drag\_targets[proxy] if proxy.\_\_is\_dmc\_drag then if ( phase == "moved" ) then -- keep the dragged item moving with the touch coordinates proxy.x = e.x + drag\_info.x\_offset proxy.y = e.y + drag\_info.y\_offset -- see if we are over any drop targets local newDropTarget = self:\_searchDropTargets( e.x, e.y ) if DragDrop.drop\_target == newDropTarget then -- same object, so call dragOver() if DragDrop.drop\_target and DragDrop.drop\_target\_accept then local o = newDropTarget local ds = self.\_registered[o] local f = ds.dragOver if f then local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then result = f( o, e ) else result = f( e ) end end end elseif DragDrop.drop\_target ~= newDropTarget then -- new target is nil, -- we exited, so call dragExit() if DragDrop.drop\_target and DragDrop.drop\_target\_accept then local o = DragDrop.drop\_target local ds = self.\_registered[o] local f = ds.dragExit if f then local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then result = f( o, e ) else result = f( e ) end end end self.drop\_target\_accept = false -- call dragEnter on newDropTarget if newDropTarget then local o = newDropTarget local ds = self.\_registered[newDropTarget] local f = ds.dragEnter if f then local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then result = f( ds.obj, e ) else result = f( e ) end end end end DragDrop.drop\_target = newDropTarget elseif phase == "ended" or phase == "cancelled" then local func if phase == "ended" then if DragDrop.drop\_target and DragDrop.drop\_target\_accept then -- same object, so call dragDrop() \_G.targetX = DragDrop.drop\_target.x local o = DragDrop.drop\_target local ds = self.\_registered[o] local f = ds.dragDrop if f then local e = self:\_createEventStructure( o, drag\_info ) if ds.call\_with\_object then result = f( o, e ) else result = f( e ) end end -- keep on Drop Target, and shrink func = self:\_createEndAnimation( { x=o.x, y=o.y, time=DragDrop.ANIMATE\_TIME\_FAST, resize=true, drag\_proxy=proxy }) else --drop not accepted, so move back to drag origin func = self:\_createEndAnimation({ x=drag\_info.origin.x, y=drag\_info.origin.y, time=DragDrop.ANIMATE\_TIME\_SLOW, resize=false, drag\_proxy=proxy }) end end self.drop\_target = nil self.drop\_target\_accept = false self:\_doDragStop( proxy ) self:\_stopListening( proxy ) func() proxy.\_\_is\_dmc\_drag = nil display.getCurrentStage():setFocus( nil ) end end return result end function DragDrop:\_createEndAnimation( params ) local params = params or {} local default\_transition\_time = 600 local fDelete, doFunc local drag\_proxy = params.drag\_proxy -- create final removal fDelete = function( e ) local dt = drag\_proxy DragDrop.\_drag\_targets[dt] = nil dt:removeSelf() end -- move and/or shrink the object local p = {} p.onComplete = fDelete p.time = params.time or default\_transition\_time p.x = params.x p.y = params.y if params.resize then p.width = 10 ; p.height = 10 end doFunc = function( e ) transition.to( drag\_proxy, p ) end return doFunc end function DragDrop:\_startListening( drag\_proxy ) local drag\_info = DragDrop.\_drag\_targets[drag\_proxy] drag\_info.proxy:addEventListener( "touch", self ) end function DragDrop:\_stopListening( drag\_proxy ) local drag\_info = DragDrop.\_drag\_targets[drag\_proxy] drag\_info.proxy:removeEventListener( "touch", self ) end function DragDrop:\_searchDropTargets( x, y ) local dropList = self.\_registered for k, \_ in pairs( dropList ) do local o = k if not isDisplayObject( k ) then o = k[DragDrop.DISPLAY\_PROPERTY] if o == nil then print( "\nWARNING: object not of type Corona Display nor does it have display property '" .. DragDrop.DISPLAY\_PROPERTY .. "'\n" ) end end --print(o.contentBounds) local bounds = o.contentBounds local isWithinBounds = bounds.xMin \<= x and bounds.xMax \>= x and bounds.yMin \<= 245 and bounds.yMax \>= 415 if isWithinBounds then return k end end return nil end return DragDrop

I would suggest looking at line 415 in your library and see why bounds is nil.  Maybe you didn’t pass a parameter right?  We really can’t support 3rd party libraries like this, so if you can’t solve an issue with his library you should probably contact him directly through his github account.

I would suggest looking at line 415 in your library and see why bounds is nil.  Maybe you didn’t pass a parameter right?  We really can’t support 3rd party libraries like this, so if you can’t solve an issue with his library you should probably contact him directly through his github account.

hi @xjs08a,

i believe that you run into that situation when there are still objects registered with the Drag Manager. you will need to call unregister() when you’re done with them.

i will be adding this code to the library very soon, but here it is for you:

function dragManager:unregister(obj) local registered = {} for k,v in pairs(self.\_registered) do if(k ~= obj) then registered[k] = v end end self.\_registered = registered local onDragStart = {} local currentOnDragStart = self.\_onDragStart if(currentOnDragStart) then for \_,item in ipairs(currentOnDragStart) do if(item ~= nil and item ~= obj) then table.insert(onDragStart, item) end end self.\_onDragStart = onDragStart end local onDragStop = {} local currentOnDragStop = self.\_onDragStop if(currentOnDragStop) then for \_, item in ipairs(currentOnDragStop) do if(item ~= nil and item ~= obj) then table.insert(onDragStop, item) end end self.\_onDragStop = onDragStop end end

cheers,
dmc

hi @xjs08a,

i believe that you run into that situation when there are still objects registered with the Drag Manager. you will need to call unregister() when you’re done with them.

i will be adding this code to the library very soon, but here it is for you:

function dragManager:unregister(obj) local registered = {} for k,v in pairs(self.\_registered) do if(k ~= obj) then registered[k] = v end end self.\_registered = registered local onDragStart = {} local currentOnDragStart = self.\_onDragStart if(currentOnDragStart) then for \_,item in ipairs(currentOnDragStart) do if(item ~= nil and item ~= obj) then table.insert(onDragStart, item) end end self.\_onDragStart = onDragStart end local onDragStop = {} local currentOnDragStop = self.\_onDragStop if(currentOnDragStop) then for \_, item in ipairs(currentOnDragStop) do if(item ~= nil and item ~= obj) then table.insert(onDragStop, item) end end self.\_onDragStop = onDragStop end end

cheers,
dmc