making a button disappear

Hi, I’m currently having some problems making a button disappear:

[lua]module(…, package.seeall)

new = function()
local ui = require(“ui”)

local testGroup = display.newGroup()

– the function to create the cancel web popup button
local createCloseButton = function()
local button = ui.newButton {
default = “closeButton.png”,
over = “closeButton_pressed.png”,
onRelease = function()
native.cancelWebPopup()
display.remove(button)
end
}
button.x = display.contentWidth - (display.contentHeight / 8)
button.y = display.contentHeight / 8
testGroup:insert(button)
end

– the button to launch the web popup
local openWebPopUp = ui.newButton {
default = “button.png”,
over = “button_pressed.png”,
onRelease = function()
native.showWebPopup(40, 40, 320, 240, “http://www.google.com”)
createCloseButton()
end
}
openWebPopUp.x = (display.contentWidth / 8) * 2
openWebPopUp.y = display.contentHeight / 8
testGroup:insert(openWebPopUp)

return testGroup
end[/lua]

The button is able to close the web popup but I also want it to close itself too. [import]uid: 71024 topic_id: 22711 reply_id: 322711[/import]

Only thing i see that could be causing a problem is that the button remove function is part of the button table. I’m not around a computer to test it but maybe try putting the function seperate and just call it from the onRelease section. That being said, have you looked at the widget.newButton api? i used to use ui.lua but switched to the widget api because it is a lot more customizable and the documentation for problems such as this is much better.
http://developer.anscamobile.com/reference/index/widgetnewbutton [import]uid: 126161 topic_id: 22711 reply_id: 90595[/import]

I did what you suggested and it works now, thanks! [import]uid: 71024 topic_id: 22711 reply_id: 90611[/import]