From the documentation buttonWidget inherits methods from groupObject which inherits methods from object. Therefor it should have a removeSelf() function.
However the folowing code snippet:
local b5
b5 = widget.newButton{
left = 10, top = 200, label = ‘B5’, onPress = function (event)
print(‘B5 pressed’, type(b5), b5.label, b5.removeSelf)
b5:removeSelf()
end,
}
prints the folowing on the console when the button is pressed:
015-04-18 18:44:04.887 Corona Simulator[26859:507] B5 pressed table B5 nil
2015-04-18 18:44:04.887 Corona Simulator[26859:507] Runtime error
/Applications/CoronaSDK/SampleCode/NativeKeyboard/main.lua:285: attempt to call method ‘removeSelf’ (a nil value)
stack traceback:
/Applications/CoronaSDK/SampleCode/NativeKeyboard/main.lua:285: in function ‘_onPress’
?: in function ‘?’
?: in function <?:1381>
?: in function <?:221>
clearly b5 does refer to the button inside the onPress fucntion because it knows the label but clearly there is no removeSelf() function.
Am I missing somthing here? Is there a way to remove a button?