function func (sel) --按钮虚拟响应效果函数
if(sel == 1) then
print("key1")
else if(sel == 2) then
print("key2")
else if(sel == 3) then
print("key3")
else
print("null")
end
end
end
end
--------------按钮函数,按钮闭包------------------
function press(key)
--key = 1
return function () return key end
end
onkey1 = press(1) --创建按钮1
onkey2 = press(2) --创建按钮2
func(onkey1()); --按钮响应
func(onkey1());
func(onkey2());
func(onkey2());