我正在做一个关于处理和使用 controlP5 的 GUI。我想用我的键盘在控件之间切换,但我失败了。
我想做的另一件事是从 TextAreas 中删除光标,因为始终是后面的字符而不是结尾处的蜜蜂。
有人知道如何实现这一目标吗?如果知识渊博的人知道怎么做,我会很高兴,我真的很猴子!
谢谢
我正在做一个关于处理和使用 controlP5 的 GUI。我想用我的键盘在控件之间切换,但我失败了。
我想做的另一件事是从 TextAreas 中删除光标,因为始终是后面的字符而不是结尾处的蜜蜂。
有人知道如何实现这一目标吗?如果知识渊博的人知道怎么做,我会很高兴,我真的很猴子!
谢谢
好吧,我确实自己弄清楚了。这些 ControlP5 并不是真正直观的控件。根本没有文档,并且示例中没有涵盖像这样的控件(可用性)中最常见的功能。可惜。无论如何,这里是:
import java.awt.event.KeyEvent;
import controlP5.*;
ControlP5 cp5;
boolean isTabPressed = false;
void keyPressed()
{
if(keyCode== TAB){
isTabPressed = !isTabPressed;
if(isTabPressed){
Textfield tf = (Textfield) cp5.getController("textValue");
tf.setFocus(true);
Textfield tf1 = (Textfield) cp5.getController("textValue1");
tf1.setFocus(false);
}else{
Textfield tf = (Textfield) cp5.getController("textValue");
tf.setFocus(false);
Textfield tf1 = (Textfield) cp5.getController("textValue1");
tf1.setFocus(true);
}
}
}
void setup()
{
size(400,180);
cp5 = new ControlP5(this);
cp5.addTextfield("textValue")
.setPosition(100, 30)
.setSize(200, 20)
.setAutoClear(false)
;
cp5.addTextfield("textValue1")
.setPosition(100, 90)
.setSize(200, 20)
.setAutoClear(false)
;
}
void draw()
{
}