I have a UI button and want to check if it’s empty (i.e if it has a blank space). If it is empty, I would like to make it invisible. If not I would like to make it visible and set it’s text to “B”. I thought the code below was going to work, however it does not. Am I doing anything wrong? Thanks for your help.
– this is the function to test if button 1 is empty
local button1Press = function( event )
if (button1.text==" ")then
button1.isVisible = false
else
button1.isVisible = true
button1:setText (“B”)
end
end
– This is code for button1
button1 = ui.newButton{
defaultSrc = “images/BVC_ORANGE_3540.png”,
overSrc = “images/BVC_ORANGE_3540.png”,
defaultX = 35, – this is the x coordinate of the button
defaultY = 40,
overX = 35,
overY = 40,
–onEvent = button1Release,
onPress = button1Press,
–onRelease = button1Release,
id = “button1”,
text = “”,
font = “Arial”,
textColor = { 51, 51, 51, 255 },
align = “left”,
size = 22,
}
button1.x=50
button1.y=60
[import]uid: 104131 topic_id: 18702 reply_id: 318702[/import]