use of javafx.scene.input.KeyEvent in project org.csstudio.display.builder by kasemir.
the class RTImagePlot method showAxisLimitsField.
private void showAxisLimitsField(AxisPart<Double> axis, boolean isHigh, Rectangle area) {
axisLimitsField.setOnKeyPressed((KeyEvent event) -> {
if (event.getCode().equals(KeyCode.ENTER)) {
hideAxisLimitsField();
if (axisLimitsField.getText().isEmpty())
return;
try {
Double value = Double.parseDouble(axisLimitsField.getText());
changeAxisLimit(axis, isHigh, value);
} catch (NumberFormatException e) {
}
} else if (event.getCode().equals(KeyCode.ESCAPE)) {
hideAxisLimitsField();
}
});
String tip = isHigh ? axis.getValueRange().getHigh().toString() : axis.getValueRange().getLow().toString();
axisLimitsField.setText(tip);
axisLimitsField.setTooltip(new Tooltip(tip));
axisLimitsField.setVisible(true);
axisLimitsField.relocate(area.getX(), area.getY());
axisLimitsField.resize(area.getWidth(), area.getHeight());
axisLimitsField.requestFocus();
// force text to appear in field
axisLimitsField.layout();
}
use of javafx.scene.input.KeyEvent in project org.csstudio.display.builder by kasemir.
the class ZoomPan method createScene.
public static Scene createScene() {
// Stuff to show as 'widgets'
final Node[] stuff = new Node[3];
for (int i = 0; i < stuff.length; ++i) {
final Rectangle rect = new Rectangle(50 + i * 100, 100, 10 + i * 50, 20 + i * 40);
rect.setFill(Color.BLUE);
stuff[i] = rect;
}
// With 'Group', stuff would start in top-left (0, 0) corner,
// not at (50, 100) based on its coordinates
final Pane widgets = new Pane(stuff);
widgets.setStyle("-fx-background-color: coral;");
final ScrollPane scroll;
if (true) {
// Additional Group to help ScrollPane get correct bounds
final Group scroll_content = new Group(widgets);
scroll = new ScrollPane(scroll_content);
} else
scroll = new ScrollPane(widgets);
final InvalidationListener resized = prop -> handleViewportChanges(scroll);
scroll.widthProperty().addListener(resized);
scroll.heightProperty().addListener(resized);
System.out.println("Press 'space' to change zoom");
final Scene scene = new Scene(scroll);
scene.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
if (event.getCode() == KeyCode.SPACE) {
zoom_in = !zoom_in;
if (zoom_in)
widgets.getTransforms().setAll(new Scale(2.5, 2.5));
else
widgets.getTransforms().setAll(new Scale(0.5, 0.5));
}
});
return scene;
}
use of javafx.scene.input.KeyEvent in project org.csstudio.display.builder by kasemir.
the class ScaledSliderRepresentation method createJFXNode.
@Override
protected GridPane createJFXNode() throws Exception {
slider.setFocusTraversable(true);
slider.setOnKeyPressed((final KeyEvent event) -> {
switch(event.getCode()) {
case PAGE_UP:
slider.adjustValue(value + slider.getBlockIncrement());
event.consume();
break;
case PAGE_DOWN:
slider.adjustValue(value - slider.getBlockIncrement());
event.consume();
break;
default:
break;
}
});
slider.setValue(value);
final GridPane pane = new GridPane();
// pane.setGridLinesVisible(true);
pane.add(markers, 0, 0);
pane.getChildren().add(slider);
return pane;
}
use of javafx.scene.input.KeyEvent in project uPMT by coco35700.
the class MainViewTransformations method addTypeListener.
public static void addTypeListener(TypeClassRepresentationController boutType, MomentExpVBox m, Type type, Main main) {
boutType.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (newPropertyValue) {
boutType.colorFocus();
} else {
boutType.resetFocusColor();
}
}
});
boutType.setOnMouseClicked(new EventHandler<Event>() {
@Override
public void handle(Event event) {
boutType.requestFocus();
}
});
boutType.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if ((event.getCode().equals(KeyCode.DELETE) || event.getCode().equals(KeyCode.BACK_SPACE)) & boutType.isFocused()) {
RemoveTypeCommand cmd = new RemoveTypeCommand(boutType, m, main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
}
}
});
}
use of javafx.scene.input.KeyEvent in project uPMT by coco35700.
the class TypeTreeViewControllerClass method rename.
@Override
public void rename() {
super.rename();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
if (type.getType().isCategory()) {
String oldName = new String(type.getType().getName());
if (!oldName.equals(textField.getText())) {
boolean hasName = false;
// System.out.println("Parent: "+type.getParent().getName());
for (Type classe : type.getParent().getTypes()) {
// System.out.println("Classes: "+classe.getName());
if (classe.getName().equals(textField.getText())) {
hasName = true;
break;
}
}
if (!hasName) {
RenameClassSchemeCommand cmd = new RenameClassSchemeCommand(type.getClassNameController(), oldName, textField.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(main._langBundle.getString("invalid_name"));
alert.setHeaderText(null);
alert.setContentText(main._langBundle.getString("class_name_invalid"));
alert.show();
}
}
}
typePane.setLeft(nomType);
rename.setDisable(false);
textField.focusedProperty().removeListener(this);
}
}
};
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (type.getType().isProperty()) {
textField.setText(textField.getText());
}
typePane.setLeft(nomType);
rename.setDisable(false);
}
if (event.getCode() == KeyCode.ESCAPE) {
typePane.setLeft(nomType);
rename.setDisable(true);
}
}
});
textField.focusedProperty().addListener(listener);
typePane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
Aggregations