use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextAreaListeners method textAreaFocusTraversalListener.
public static EventListener textAreaFocusTraversalListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextArea = (DialogSceneComposerModel.SimTextArea) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Focus Traversal:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextArea.focusTraversal ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.focusTraversal);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the TextArea allows for the use of focus traversal keys.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textAreaFocusTraversal(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextAreaListeners method textAreaSelectionListener.
public static EventListener textAreaSelectionListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextArea = (DialogSceneComposerModel.SimTextArea) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var table = new Table();
popTable.add(table);
var positionLabel = new Label("Cursor Position: (" + simTextArea.cursorPosition + ")", skin, "scene-label-colored");
table.add(positionLabel);
table.row();
var slider = new Slider(0, simTextArea.text == null ? 0 : simTextArea.text.length(), 1, false, skin, "scene");
slider.setValue(simTextArea.cursorPosition);
table.add(slider).minWidth(200);
slider.addListener(handListener);
slider.addListener(new TextTooltip("The cursor position when the TextArea has keyboard focus.", tooltipManager, skin, "scene"));
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textAreaCursorPosition(MathUtils.round(slider.getValue()));
positionLabel.setText("Cursor Position: (" + simTextArea.cursorPosition + ")");
}
});
table.row();
var selectionLabel = new Label("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")", skin, "scene-label-colored");
table.add(selectionLabel);
table.row();
var rangeSlider = new RangeSlider(skin, "scene");
rangeSlider.setMinimum(0);
rangeSlider.setMaximum(simTextArea.text == null ? 0 : simTextArea.text.length());
rangeSlider.setIncrement(1);
rangeSlider.setValueBegin(simTextArea.selectionStart);
rangeSlider.setValueEnd(simTextArea.selectionEnd);
rangeSlider.setDisabled(simTextArea.selectAll);
table.add(rangeSlider).minWidth(200);
rangeSlider.getKnobBegin().addListener(handListener);
rangeSlider.getKnobEnd().addListener(handListener);
rangeSlider.addListener(new TextTooltip("The text range to be selected if this TextArea has keyboard focus.", tooltipManager, skin, "scene"));
rangeSlider.addListener(new ValueBeginChangeListener() {
@Override
public void changed(ValueBeginChangeEvent event, float value, Actor actor) {
events.textAreaSelectionStart(MathUtils.round(value));
}
});
rangeSlider.addListener(new ValueEndChangeListener() {
@Override
public void changed(ValueEndChangeEvent event, float value, Actor actor) {
events.textAreaSelectionEnd(MathUtils.round(value));
}
});
rangeSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
selectionLabel.setText("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")");
}
});
table.row();
var label = new Label("Select All: ", skin, "scene-label-colored");
table.add(label);
table.row();
var textButton = new TextButton(simTextArea.selectAll ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.selectAll);
table.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Convenience option to select all text.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textAreaSelectAll(textButton.isChecked());
rangeSlider.setDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextAreaListeners method textAreaDisabledListener.
public static EventListener textAreaDisabledListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextArea = (DialogSceneComposerModel.SimTextArea) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Disabled:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextArea.disabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.disabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the TextArea is disabled initially.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textAreaDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextFieldListeners method textFieldMaxLengthListener.
public static EventListener textFieldMaxLengthListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextField = (DialogSceneComposerModel.SimTextField) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var table = new Table();
popTable.add(table);
var label = new Label("Max Length:", skin, "scene-label-colored");
table.add(label).right();
var valueSpinner = new Spinner(simTextField.maxLength, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
valueSpinner.setMinimum(0);
table.add(valueSpinner).width(100).left();
valueSpinner.getTextField().addListener(ibeamListener);
valueSpinner.getButtonMinus().addListener(handListener);
valueSpinner.getButtonPlus().addListener(handListener);
valueSpinner.addListener(new TextTooltip("The maximum length of characters allowed in the TextField.", tooltipManager, skin, "scene"));
valueSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldMaxLength(valueSpinner.getValueAsInt());
}
});
table.row();
label = new Label("(Set to 0 to show as many as possible)", skin, "scene-label-colored");
table.add(label).colspan(2);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextFieldListeners method textFieldNameListener.
public static EventListener textFieldNameListener(final DialogSceneComposer dialogSceneComposer) {
var simTextField = (DialogSceneComposerModel.SimTextField) dialogSceneComposer.simActor;
var textField = new TextField("", skin, "scene");
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Name:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(simTextField.name);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The name of the TextField to allow for convenient searching via Group#findActor().", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.textFieldName(textField.getText());
}
});
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
popTable.hide();
return true;
} else {
return false;
}
}
});
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations