How to hide widget?

Hi,

I am using widget buttons to create a small user text input. When the user clicks the widget it adds a letter to the input field. I am only wanting the user to be able to click the widget once and then it is removed but removed in a way that it can be easily put back in place if the user cancels his input field to start again.

Heres the code, it works perfectly adding the letter to the input field but as I said I want to easily remove and reinstate it:

local sButton = widget.newButton

    {

        cornerRadius = 4,

        onEvent = 

        function() 

        answerString.text = answerString.text…“S” 

        end,

        id = “sButton1”,

        label = “S”,

        width = 60, height = 60,

        fontSize = 30,

        emboss = true,

        font = “Pieces of Eight”

    }

    group:insert( sButton )

    sButton.y = display.contentHeight * 1

any help would be greatly appreciated!!

Hi @mickc92,

Probably the easiest way is to just hide and un-hide the display group that you placed the button in. When it’s hidden, Corona should not sense any touch upon it, so effectively that’s just as good as removing the button (but it won’t be gone forever, and you can just make the group visible again to restore it).

Does that help?

Brent

brilliant thanks, worked like a charm!

Hi @mickc92,

Probably the easiest way is to just hide and un-hide the display group that you placed the button in. When it’s hidden, Corona should not sense any touch upon it, so effectively that’s just as good as removing the button (but it won’t be gone forever, and you can just make the group visible again to restore it).

Does that help?

Brent

brilliant thanks, worked like a charm!