How do I create a transparent button in Java Script (Smartface)

122 Views Asked by At

I am just trying to make a transparent button in the smartface cloud IDE using java script, and every time I make it transparent it wont read a click. I can increase the opacity all the way to alpha = .1 but when I set it equal to zero it wont work. How can I fix this, or is there another way to do this. I just want the button to take this form...

left : "50%", top : "50%", height : "50%", width : "50%", (The bottom right hand corner)

This is the code I have for the button (It doesn't work)

var myTextBtn = new SMF.UI.TextButton({
    left : '50%',
    top : '50%',
    width : '50%',
    height : '50%',
    text : "",
    onPressed : alert("Pressed"),
});
myTextBtn.alpha = 0;
page1.add(myTextBtn);
1

There are 1 best solutions below

3
halit On

alpha shouldn't affect click unless it is 0. The problem is onPressed accepts callback function. But you are calling alert function there and giving its result to onPressed property.

Try this:

var myTextBtn = new SMF.UI.TextButton({
    left : '50%',
    top : '50%',
    width : '50%',
    height : '50%',
    text : "",
    onPressed : function() {
        alert("Pressed");
    }
});
myTextBtn.alpha = 0.5;
page1.add(myTextBtn);