[Resolved] How to focus on Button instead of Background?

Dear master,

i have my program with one background & one image

 -----------------------------------------------------------------------------  
 -- my background  
 dObjStickBoard = display.newImage('iphone\_bg\_hr.png')  
 dObjStickBoard:setReferencePoint(display.TopLeftReferencePoint)  
 dObjStickBoard.x, dObjStickBoard.y = 0, 0  
 dObjStickBoard.alpha = 0.5  
  
 -- my button  
 dObjConfig = sprtGen:grabSprite('ico-setting', true)  
 dObjConfig:setReferencePoint(display.TopLeftReferencePoint)  
  
 dObjConfig.x, dObjConfig.y= 10, 522  
  
 -- event  
 local function onEventConfig(event)  
 local t = event.target  
 if event.phase == 'began' then  
 display.getCurrentStage():setFocus( t )  
 end  
 if event.phase == 'ended' then  
 print('config clicked')  
 end  
 if event.phase == 'ended' or event.phase == 'cancelled' then  
 display.getCurrentStage():setFocus(nil)  
 end  
  
 end  
 local function onEventStickBoard(event)  
 local t = event.target  
 if event.phase == 'began' then  
 display.getCurrentStage():setFocus( t )  
 end  
  
 if event.phase == 'ended' then  
 print('stick board clicked')  
 end  
  
 if event.phase == 'ended' or event.phase == 'cancelled' then  
 display.getCurrentStage():setFocus(nil)  
 end  
  
  
 end  
  
  
 dObjStickBoard:addEventListener('touch', onEventStickBoard)  
 dObjConfig:addEventListener('touch', onEventConfig)  

with code above, it always show ‘stick board clicked’ message in Terminal regardless i clicked on background or button. Is there a way to rectify this? i need the button to fire when button is clicked, and background event to fire only when background is clicked.

Thanks for the pointers [import]uid: 10373 topic_id: 25776 reply_id: 325776[/import]

Between lines 25 and 26 in the above try adding [lua]return true[/lua] :slight_smile: [import]uid: 52491 topic_id: 25776 reply_id: 104244[/import]

it WORKED! Thanks Peach! [import]uid: 10373 topic_id: 25776 reply_id: 104299[/import]

Not a problem, good luck with the rest of your project :slight_smile: [import]uid: 52491 topic_id: 25776 reply_id: 104377[/import]