简体   繁体   English

如何在Java脚本(Smartface)中创建透明按钮

[英]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.

相关问题 如何使用JavaScript创建透明按钮? - How can I create a transparent button with JavaScript? 如何使用JavaScript在smartface,io IDE中旋转此图像? - How do I rotate this image in the smartface,io IDE using javascript? 如何为 2 个单选按钮选择编写 Java 脚本计算? - How do I write Java Script calculation for 2 radio button selections? 如何使用 Java 脚本中的按钮更改文本的颜色? - How do I change the color of a text with a button in Java Script? 如何使用Java脚本为游戏创建重启按钮 - How to create a restart button for a game in Java Script 如何在 openlayers 3 的地图上创建一个半径可调的透明圆 - how do I create a transparent circle with adjustable radius on a map in openlayers 3 如何在java脚本中使用回车键触发按钮?/如何给文本框和搜索按钮一个ID? - how do i trigger a button with the enter key in java script?/ how to give text box and search button an ID? 如何通过按钮在 java 脚本中增加 function 中的全局变量? - How do i increment a global variable in a function in java script from a button? 单击素面中的命令按钮时如何调用Java脚本函数 - How do i invoke a java script function when clicking on command button in prime faces 如何在按钮单击时创建卡片? - How do I create a card on button click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM