Disable button in sliding menu corona

Hello everyone, I have a quick question about disabling button.
I am new to the forum and here is my first question (probably wont be the last :wink: )
I have created a sliding menu using rob’s tutorial https://coronalabs.com/blog/2014/08/19/tutorial-building-a-sliding-menu/
Each button of the sliding menu is a level and the idea is to enable a button only if the previous level has been finished. So if I start the app for the first time, only button 1 should be enabled and the other ones disabled.
I use a variable ‘highScores’ to know if the level has been finished.
I found something related to this on the forum: https://forums.coronalabs.com/topic/36863-enabledisable-button/
it seems that the problem comes from the touch handler added to the button that creates the problem. However here, I am not sure how can get rid of the handler in the sliding menu.
 
I have tried to use object:setEnabled(false) in both the the showSlidingMenu and iconListener functions but without succes.
 
Could someone help me with this please?
 
Thanks in advance:
here is the code:
 
 
 

local function iconListener( event )   local id = event.target.id if ( event.phase == "moved" ) then     local dx = math.abs( event.x - event.xStart )      if ( dx \> 5 ) then scrollView:takeFocus( event ) end elseif ( event.phase == "ended" ) then print( "object", id, "was touched" ) buttonListAdditionId = id composer.removeScene("blabla") composer.gotoScene("blabla1") timer.performWithDelay( 10, function() scrollView:removeSelf(); scrollView = nil; end ) end return true end local function showSlidingMenu() scrollView = widget.newScrollView { width = display.actualContentWidth, height = display.actualContentHeight, scrollWidth = display.actualContentWidth/2, scrollHeight = display.actualContentHeight/2, horizontalScrollDisabled = true, hideBackground = true } scrollView.x = display.contentCenterX scrollView.y = display.contentCenterY   for i = 1, 10 do icons[i] = widget.newButton({ label = "blabla "..i..":", emboss = true, defaultFile = "Images/scrollView.png", labelAlign = "left", width = display.actualContentWidth, onPress = onButton }) icons[i].y = (display.contentHeight/6) \* i icons[i].anchorY = 1 scrollView:insert( icons[i] ) icons[i].id = i icons[i]:addEventListener( "touch", iconListener ) listBestScore[i] = display.newText("Best score: "..highScores[i], display.contentWidth- icons[i].x/2 , icons[i].y - icons[1].y, native.systemFontBold, 15 ) scrollView:insert(listBestScore[i]) end for i = 2, 10 do if highScores[i-1] == 0 then icons[i]:setEnabled( false ) end end

Hi everyone,

I managed to correct the problem myself today.

Cheers all

Hi everyone,

I managed to correct the problem myself today.

Cheers all