I’ll post a video: at around 0:02-0:10 you will notice a button doesn’t respond well on touch, what seems to be the problem?
the Device is Nexus 4 and 5
Android:
Video: http://youtu.be/eaX4FM_HDKQ
My code:
–Creating the boxes(the box is the only thing with touch event)
for i = 1,#arrayLabels do --Box of the Button mainMenuButtonBox[i] = display.newRect(0,0, display.contentWidth,65) mainMenuButtonBox[i].x = display.contentWidth/2 mainMenuButtonBox[i].y = Y mainMenuButtonBox[i].name = arrayLabels[i].name mainMenuButtonBox[i].part = "box" mainMenuButtonBox[i].number = i mainMenuButtonBox[i].touch = onObjectTouch mainMenuButtonBox[i].isDropped = "no" mainMenuButtonBox[i].isEnabled = "true" mainMenuButtonBox[i].isDropDowns = arrayLabels[i].isDropDown mainMenuButtonBox[i].numberOfSubs = arrayLabels[i].numberOfSub --Change this to change color of the button box mainMenuButtonBox[i]:setFillColor(1,1,1) end
(Touch Listener Function)
function reEnable() for i=1,#arrayLabels do mainMenuButtonBox[i].isEnabled = "true" end end --Function for Object Touch function onObjectTouch(self,event) if event.phase == "began" then clickedNumber = self.number display.getCurrentStage():setFocus( event.target ) --'event.target' is the touched object if self.isDropped == "yes" then mainMenuButtonDropIcon[self.number]:setFrame(4) else if self.isDropDowns == "yes" then mainMenuButtonDropIcon[self.number]:setFrame(2) end end mainMenuButtonBox[self.number]:setFillColor(0.184, 0.686, 0.878) mainMenuButtonTitles[self.number]:setFillColor(1,1,1) mainMenuButtonFiller[self.number]:setFillColor(1,1,1) elseif event.phase == "moved" then scrollViewMain:takeFocus(event) elseif event.phase == "ended" or event.phase == "cancelled" then display.getCurrentStage():setFocus( nil ) --setting focus to 'nil' removes the focus --Check if button is drop down or naht if self.isEnabled == "false" then --Put nothing here for now else --1 if self.name == "Metro Manila" then print("About") if self.dropDown == "yes" then if self.isDropped == "no" then mainMenuButtonDropIcon[self.number]:setFrame(3) self.isDropped = "yes" DropDownBoxes(self) unfoldPanel(self) scrollHeight = scrollHeight+mainMenuButtonSubButton[self.number].overAll scrollViewMain:setScrollHeight(scrollHeight) greyBGHeight = greyBGHeight+mainMenuButtonSubButton[self.number].overAll greyBG.height = greyBGHeight else mainMenuButtonDropIcon[self.number]:setFrame(1) self.isDropped = "no" returnDropDownBoxes(self) foldPanel(self) scrollHeight = scrollHeight-mainMenuButtonSubButton[self.number].overAll scrollViewMain:setScrollHeight(scrollHeight) greyBGHeight = greyBGHeight-mainMenuButtonSubButton[self.number].overAll greyBG.height = greyBGHeight end elseif self.dropDown == "no" then gotoPage("About","TopLevelMenu") reEnable() end --2 elseif self.name == "Luzon" then print("News") if self.dropDown == "yes" then if self.isDropped == "no" then mainMenuButtonDropIcon[self.number]:setFrame(3) self.isDropped = "yes" DropDownBoxes(self) unfoldPanel(self) scrollHeight = scrollHeight+mainMenuButtonSubButton[self.number].overAll scrollViewMain:setScrollHeight(scrollHeight) greyBGHeight = greyBGHeight+mainMenuButtonSubButton[self.number].overAll greyBG.height = greyBGHeight else mainMenuButtonDropIcon[self.number]:setFrame(1) self.isDropped = "no" returnDropDownBoxes(self) foldPanel(self) scrollHeight = scrollHeight-mainMenuButtonSubButton[self.number].overAll scrollViewMain:setScrollHeight(scrollHeight) greyBGHeight = greyBGHeight-mainMenuButtonSubButton[self.number].overAll greyBG.height = greyBGHeight end elseif self.dropDown == "no" then gotoPage("News","TopLevelMenu") reEnable() end end
BTW this object is in a scrollview