Remove self method in button widget missing?

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?

I think I solved it.  b5 was double defined and the second definition overode some properties.

Glad you solved it.  I did a quick test:

local widget = require("widget") local b5 local function onPress( event ) &nbsp;&nbsp;&nbsp; print("B5 pressed") &nbsp;&nbsp;&nbsp; timer.performWithDelay(3000, function() event.target:removeSelf(); end) end b5 = widget.newButton{ &nbsp;&nbsp;&nbsp; left = 10, &nbsp;&nbsp;&nbsp; top = 200, &nbsp;&nbsp;&nbsp; label = 'B5', &nbsp;&nbsp;&nbsp; onPress = onPress, }

Rob

I think I solved it.  b5 was double defined and the second definition overode some properties.

Glad you solved it.  I did a quick test:

local widget = require("widget") local b5 local function onPress( event ) &nbsp;&nbsp;&nbsp; print("B5 pressed") &nbsp;&nbsp;&nbsp; timer.performWithDelay(3000, function() event.target:removeSelf(); end) end b5 = widget.newButton{ &nbsp;&nbsp;&nbsp; left = 10, &nbsp;&nbsp;&nbsp; top = 200, &nbsp;&nbsp;&nbsp; label = 'B5', &nbsp;&nbsp;&nbsp; onPress = onPress, }

Rob