Problem with display.screenCapture, Please help!

I have an issue with a button. I created a button that triggers a main function but wanted my users to save the result as a screenshot, this works. The problem is when I click the screenshot button it cancels out my other button which is the button that triggers the main function in my app so when I try press the main button it does nothing. If I press the main button before my screenshot button, it works just fine, but as soon as I press the screenshot button, the main button no longer works, I get no errors it simply does nothing.

Here is the screenshot buttons code: 

local function okDone(event) if (event.action == "clicked") then if(event.index == 1) then return true elseif (event.action == "cancelled") then end end end --Save button function local function saveTapped(event) print ("it goes to the right function") screenShot = display.captureScreen(true) local alert=native.showAlert( "Saved!", "Saved to photo album", {"ok"}, okDone ) return true end --end save function -- Save Button saveBtn = widget.newButton { id = "SaveButton", label = "Save Result", default = { 255, 255, 255, 90 }, over = { 120, 53, 128, 255 }, } saveBtn.x = centerX saveBtn.y= display.actualContentHeight \*.763 --End Save

And here is the main buttons code:

--Button Handler local function btnOnPressHandler() resulter(distanceData, connData, spliceData, distLoss, conLoss, spliceLoss ) end local function btnOnReleaseHandler() print ("Released") end --Create button button1 = widget.newButton( { id= "button 1", left = screenLeft, top = screenTop, label = "Calculate Loss", width = 256, height = 56, --font = "native.systemFont", --fontSize = 27, labelColor = { default={0,0,0}, over= {255,255,255} }, defaultColor={201,107,61}, overColor = {219,146,85}, onPress = btnOnPressHandler , onDrag = btnOnDragHandler, onRelease = btnOnReleaseHandler }) button1.x = centerX button1.y = display.actualContentHeight \*.811

I removed the screenCapture and the button works fine. Everything works up until the screenCapture, as soon as the app hits screenCapture the app pretty much stops working, I can keep capturing the screen, the button wont animate or change colors and the main button does nothing but the capture button still lets me capture the screen, despite the button not responding by changing colors. 

I have no idea why display.captureScreen is breaking my code. When I remove captureScreen from the function the button triggers when tapped, everything works fine. But when I add captureScreen to the function my app just stops working. I get no errors but after pressing the button the triggers captureScreen nothing else works after. 

From the display.captureScreen() doc page:

“Calling this method places the captured image on the screen on top of all other display objects. Use object:removeSelf() to remove this object from the screen (as with any other display object).”

It sounds to me like you might be looking at the capture, on top of your app display… try a screenshot:removeSelf() after you take the image…

Thank you that worked like a charm

I removed the screenCapture and the button works fine. Everything works up until the screenCapture, as soon as the app hits screenCapture the app pretty much stops working, I can keep capturing the screen, the button wont animate or change colors and the main button does nothing but the capture button still lets me capture the screen, despite the button not responding by changing colors. 

I have no idea why display.captureScreen is breaking my code. When I remove captureScreen from the function the button triggers when tapped, everything works fine. But when I add captureScreen to the function my app just stops working. I get no errors but after pressing the button the triggers captureScreen nothing else works after. 

From the display.captureScreen() doc page:

“Calling this method places the captured image on the screen on top of all other display objects. Use object:removeSelf() to remove this object from the screen (as with any other display object).”

It sounds to me like you might be looking at the capture, on top of your app display… try a screenshot:removeSelf() after you take the image…

Thank you that worked like a charm