2011-06-11 30 views
2

我uisng scrollView.lua的滾動,但要出來的話,我需要把後退按鈕上但對於滾動視圖沒有任何按鍵操作事件如何將按鈕添加到scrollView併爲使用corona sdk的事件添加事件?

local menuBtn 
    local onMenuBtn = function(event) 
      if event.phase == "release" then 

      print ("I am in onMenuBtn btn action") 

      scrollView:removeSelf(); scrollView = nil 
      menuBtn:removeSelf(); menuBtn = nil 

      director:changeScene("slide1") 

      end 


     end 
     menuBtn = ui.newButton 
     { 
      defaultSrc = "menubtn.png", 
      defaultX = 100, 
      defaultY = 42, 
      overSrc = "menubtn.png", 
      overX = 100, 
      overY = 42, 
      onEvent = onMenuBtn, 
      id = "menuBtn", 
      text = "", 
      font = "Helvetica", 
      textColor = { 255, 255, 255, 255 }, 
      size = 16, 
      emboss = false 
     } 
     menuBtn.x = 50 
     menuBtn.y = 30 
     scrollView:insert(menuBtn) 

請任何一個幫助我

謝謝 馬丹磨憨

回答

1

試試這個:

local listener 

function listener:tap(event) 
    onMenuBtn(event) --or just put your code straight here 
end 

menuBtn:addEventListener("tap", listener); 
相關問題