本文整理汇总了Java中com.kotcrab.vis.ui.widget.VisTextField类的典型用法代码示例。如果您正苦于以下问题:Java VisTextField类的具体用法?Java VisTextField怎么用?Java VisTextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VisTextField类属于com.kotcrab.vis.ui.widget包,在下文中一共展示了VisTextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContentBox
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
private static Table createContentBox() {
Table contentBox = new Table();
VisTextField textField = new VisTextField();
textField.setMessageText(Translation.get("InsNewDBName").toString());//TODO change to CharSequence
CharSequenceCheckBox checkBox = new CharSequenceCheckBox(Translation.get("UseDefaultRep"));
float pad = CB.scaledSizes.MARGIN;
contentBox.add(textField).pad(pad).left().fillX();
contentBox.row();
contentBox.add(checkBox).pad(pad).left().fillX();
contentBox.pack();
contentBox.layout();
return contentBox;
}
示例2: updateMapListener
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
private Listener updateMapListener(final VisTextField textField) {
return new Listener() {
@Override
public void invoke() {
// TODO: null checks
try {
final MapDefinition current = Editor.db().map(textField.getText());
if (current != null) {
definition = current;
updateMap();
}
} catch (NullPointerException e) {
// couldn't find the map, no worries -- clear any old maps out
mapTable.clear();
}
}
};
}
示例3: process
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final VisTextField actor,
final String rawAttributeData) {
@SuppressWarnings("unchecked") final ActorConsumer<Boolean, Character> filter = (ActorConsumer<Boolean, Character>) parser
.parseAction(rawAttributeData, Character.valueOf(' '));
if (filter == null) {
parser.throwErrorIfStrict(
"Text field filter attribute requires ID of an action that consumes a Character and returns a boolean or Boolean. Valid action not found for name: "
+ rawAttributeData);
return;
}
actor.setTextFieldFilter(new TextFieldFilter() {
@Override
public boolean acceptChar(final VisTextField textField, final char character) {
return filter.consume(character);
}
});
}
示例4: process
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final VisTextField actor,
final String rawAttributeData) {
final ActorConsumer<?, Character> listener = parser.parseAction(rawAttributeData, Character.valueOf(' '));
if (listener == null) {
parser.throwErrorIfStrict(
"Text field listener attribute requires ID of an action that consumes a Character. Valid action not found for name: "
+ rawAttributeData);
return;
}
actor.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(final VisTextField textField, final char character) {
listener.consume(character);
}
});
}
示例5: acceptChar
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
@Override
public boolean acceptChar (VisTextField field, char c) {
int selectionStart = field.getSelectionStart();
int cursorPos = field.getCursorPosition();
String text;
if (field.isTextSelected()) { //issue #131
String beforeSelection = field.getText().substring(0, Math.min(selectionStart, cursorPos));
String afterSelection = field.getText().substring(Math.max(selectionStart, cursorPos));
text = beforeSelection + afterSelection;
} else {
text = field.getText();
}
if (c == '.' && text.contains(".") == false) return true;
return super.acceptChar(field, c);
}
示例6: createHexTable
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
private VisTable createHexTable () {
VisTable table = new VisTable(true);
table.add(new VisLabel(HEX.get()));
table.add(hexField = new VisValidatableTextField("00000000")).width(HEX_FIELD_WIDTH * sizes.scaleFactor);
table.row();
hexField.setMaxLength(HEX_COLOR_LENGTH);
hexField.setProgrammaticChangeEvents(false);
hexField.setTextFieldFilter(new TextFieldFilter() {
@Override
public boolean acceptChar (VisTextField textField, char c) {
return Character.isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
});
hexField.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
if (hexField.getText().length() == (allowAlphaEdit ? HEX_COLOR_LENGTH_WITH_ALPHA : HEX_COLOR_LENGTH)) {
setColor(Color.valueOf(hexField.getText()), false);
}
}
});
return table;
}
示例7: TestIssue131
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
public TestIssue131 () {
super("issue #131");
TableUtils.setSpacingDefaults(this);
columnDefaults(0).left();
VisTextField field1 = new VisTextField("0.1234");
VisTextField field2 = new VisTextField("4.5678");
field1.setTextFieldFilter(new FloatDigitsOnlyFilter(true));
field2.setTextFieldFilter(new FloatDigitsOnlyFilter(true));
add(new LinkLabel("issue #131 - decimal point lost", "https://github.com/kotcrab/vis-editor/issues/131")).colspan(2).row();
add(field1);
add(field2);
setResizable(true);
setModal(false);
addCloseButton();
closeOnEscape();
pack();
centerWindow();
}
示例8: IndeterminateTextField
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
public IndeterminateTextField (VisValidatableTextField textField) {
this.textField = textField;
textField.setStyle(new VisTextField.VisTextFieldStyle(textField.getStyle()));
textField.setProgrammaticChangeEvents(false);
textField.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
if (indeterminate) {
textField.getStyle().fontColor = Color.WHITE;
indeterminate = false;
}
text = textField.getText();
}
});
text = textField.getText();
}
示例9: getInputTextStyle
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
public TextField.TextFieldStyle getInputTextStyle(){
if (inputTextFieldStyle == null){
VisTextField.VisTextFieldStyle visTextFieldStyle = VisUI.getSkin().get(VisTextField.VisTextFieldStyle.class);
inputTextFieldStyle = new TextField.TextFieldStyle(getTextInputFont(),
Color.WHITE,
visTextFieldStyle.cursor,
visTextFieldStyle.selection,
visTextFieldStyle.background
);
}
return inputTextFieldStyle;
}
示例10: createWidgets
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
private void createWidgets() {
float width = Gdx.graphics.getWidth();
if (value instanceof Integer) {
numPad = new NumPad(numPadKeyListener, width, OK, CANCEL, DelBack);
} else if (value instanceof Double) {
numPad = new NumPad(numPadKeyListener, width, OK, CANCEL, DOT, DelBack);
} else if (value instanceof Float) {
numPad = new NumPad(numPadKeyListener, width, OK, CANCEL, DOT, DelBack);
} else throw new NotImplementedException("Ilegal Number type");
textField = new VisTextField(value.toString());
textField.setOnscreenKeyboard(numPad);
}
示例11: KeyPressed
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
@Override
public void KeyPressed(String value) {
if ("C".equals(value)) {
cancelListener.clicked(StageManager.BACK_KEY_INPUT_EVENT, -1, -1);
return;
}
if (actFocusField != null) {
getStage().setKeyboardFocus(actFocusField);
actFocusField.focusGained();
VisTextField.TextFieldClickListener listener = (VisTextField.TextFieldClickListener) actFocusField.getDefaultInputListener();
if (value.equals("<") || value.equals(">")) {
if (value.equals("<")) {
listener.keyDown(null, Input.Keys.LEFT);
} else {
listener.keyDown(null, Input.Keys.RIGHT);
}
return;
}
if (value.equals("D")) {
listener.keyTyped(null, DELETE);
return;
}
if (value.equals("B")) {
listener.keyTyped(null, BACKSPACE);
return;
}
listener.keyTyped(null, value.charAt(0));
}
}
示例12: addEditLine
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
private void addEditLine(CharSequence name, final VisTextField textField, CharSequence unity) {
Table line = new VisTable();
line.defaults().pad(CB.scaledSizes.MARGINx2);
line.add(name).left();
//disable onScreenKeyboard
textField.setOnscreenKeyboard(new TextField.OnscreenKeyboard() {
@Override
public void show(boolean visible) {
// do nothing
// we use own NumPad
}
});
textField.addListener(new FocusListener() {
public void keyboardFocusChanged(FocusListener.FocusEvent event, Actor actor, boolean focused) {
if (focused == true) {
if (actor == textField) {
actFocusField = textField;
}
}
}
});
line.add(textField).expandX().fillX();
line.add(unity);
this.row();
this.add(line).expandX().fillX();
}
示例13: isTextFitTextField
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
/** Checks if the text could fit the current textField's width. */
public static boolean isTextFitTextField(VisTextField textField, String text) {
float availableWidth = textField.getWidth();
Drawable fieldBg = textField.getStyle().background;
if (fieldBg != null) {
availableWidth = availableWidth - fieldBg.getLeftWidth() - fieldBg.getRightWidth();
}
BitmapFont font = textField.getStyle().font;
return isTextFitWidth(font, availableWidth, text);
}
示例14: TextFieldWithLabel
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
public TextFieldWithLabel(String labelText, int width) {
super();
this.width = width;
textField = new VisTextField();
label = new VisLabel(labelText);
setupUI();
}
示例15: FileChooserField
import com.kotcrab.vis.ui.widget.VisTextField; //导入依赖的package包/类
public FileChooserField(int width) {
super();
this.width = width;
textField = new VisTextField();
fcBtn = new VisTextButton("Select");
setupUI();
setupListeners();
}