Button Drag selection Question

Greeting Gurus,
 
i would like to create a similar game (as attached screenshot)
Player can chose to drag-select similar color (NOT SWAP)
 
As per screenshot, player select yellow brick in second row, drag up (select), then drag right. All 4 bricks was selected.
 
How can i perform such trick? i have created all brick as buttons.
But what understand are touch, cancelled, how can the magic to remain first one touch and to touch second button?

Here my code. Hope to get some pointers :slight_smile:

Thank you~

Codes

function BLOCK:createBlock(name)

    

    

    local function onBlockEvent(event)

            local phase = event.phase 

        

        if “ended” == phase then

            print( “You pressed and released a button!” )

            

        end

    end

    

    local block = widget.newButton {

… button creation

 

            }

    

    return block

end