[英]How do I create a transparent button in Java Script (Smartface)
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. 我只是想使用Java脚本在smartface云IDE中创建一个透明按钮,并且每次使它透明时,它都不会读取单击。 I can increase the opacity all the way to alpha = .1 but when I set it equal to zero it wont work. 我可以一直将不透明度增加到alpha = .1,但是当我将其设置为零时,它将不起作用。 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) 左:“ 50%”,上:“ 50%”,高度:“ 50%”,宽度:“ 50%”,(右下角)
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);
alpha
shouldn't affect click unless it is 0
. 除非为0
否则alpha
不会影响点击。 The problem is onPressed
accepts callback function. 问题是onPressed
接受回调函数。 But you are calling alert
function there and giving its result to onPressed
property. 但是您在此处调用alert
功能并将其结果提供给onPressed
属性。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.