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