- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Processing 创建数字键盘。我正在为 gui 使用平板电脑和 controlP5 库,然后将值发送到 arduino。我在用数字命名我的按钮时遇到问题。这是我创建按钮的代码:
n1=cp5.addButton("one",1)
.setPosition(470,390)
.setSize(100,100)
;
n2=cp5.addButton("two",2)
.setPosition(590,390)
.setSize(100,100)
;
...和其他一些。
我想用数字命名我的按钮(以便在我的屏幕上显示数字),但按钮的名称也是此处用于发送与按钮关联的值的函数的名称:
void one(int theValue)
{
buttonText= "OFF" ;
background(236, 240, 241);
sendLetter = "b" ;
byte [] myByte = stringToBytesUTFCustom(sendLetter);
sendReceiveBT.write(myByte);
}
void two(int theValue)
{
buttonText= "OFF" ;
background(236, 240, 241);
sendLetter = "c" ;
byte [] myByte = stringToBytesUTFCustom(sendLetter);
sendReceiveBT.write(myByte);
}
问题是我无法将我的按钮命名为“1”,它不起作用,因为 controlP5 试图找到具有给定名称的方法并将其链接到 Controller ,并且方法不能用单个数字命名.我必须将它命名为“一”,对于数字键盘来说有点难看。
我的问题:有没有办法在不影响用于将值发送到 arduino 的函数的情况下显示数字?
最佳答案
您可以使用setCaptionLabel(String)
来设置按钮的可见标签:
n1=cp5.addButton("one",1)
.setCaptionLabel("1")
.setPosition(470,390)
.setSize(100,100)
;
摘自此讨论:http://processing.org/discourse/beta/num_1230541431.html#5
关于button - 控件 P5 - 在按钮标签中显示数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23864559/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!