I created a function (listener) which runs on pressing button (widget). The function moves the object:toFront(). Here is the code
--------------------------- start of scene create
local DecoImg
local function handlerButton(event)
If(“ended”==event.phase) then
— here create new display.newImage at same position as DecoImg but not added to sceneGroup and newImage is still visible above decoImg
DecoImg:toFront() --not working
end
end
local button1 = widget.newButton
{
width = 100, height = 50,
defaultFile = “button-norm.png”,
overFile = “button-push.png”,
label = “button”,
onEvent = handlerButton
}
button1.x = display.contentCenterX
button1.y = 50
sceneGroup:insert(button1)
DecoImg = display.newImage…
sceneGroup:insert(DecoImg)
------------------------ end of Scene create