本文整理汇总了Java中javafx.scene.input.InputEvent类的典型用法代码示例。如果您正苦于以下问题:Java InputEvent类的具体用法?Java InputEvent怎么用?Java InputEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputEvent类属于javafx.scene.input包,在下文中一共展示了InputEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleKeyInput
import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
* Handle action related to input (in this case specifically only responds
* to keyboard event CTRL-A).
*
* @param event Input event.
*/
@FXML
public void handleKeyInput(final InputEvent event) {
if (event instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent) event;
if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
provideAboutFunctionality();
} else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.R) {
showReportOptionsDialog();
} else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.O) {
openFixturesFile();
} else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.S) {
saveFixturesFile();
} else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.L) {
showLoggerDialog();
}
}
}
示例2: justKidding
import javafx.scene.input.InputEvent; //导入依赖的package包/类
public void justKidding() {
Node node = new Region();
InputMap<InputEvent> im = sequence(
consume(keyPressed(UP), e -> moveUp()),
consume(keyPressed(DOWN), e -> moveDown()),
consume(keyPressed(LEFT), e -> moveLeft()),
consume(keyPressed(RIGHT), e -> moveRight()),
consume(
mouseMoved().onlyIf(MouseEvent::isPrimaryButtonDown),
e -> move(e.getX(), e.getY())));
Nodes.addFallbackInputMap(node, im);
Nodes.removeInputMap(node, im);
}
示例3: showDetails
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private void showDetails(InputEvent evt, double x, double y) {
DateControl control = getDateControl();
/*
* We might run in the sampler application. Then the entry view will not
* be inside a date control.
*/
if (control != null && getParent() != null) {
Callback<EntryDetailsParameter, Boolean> callback = control.getEntryDetailsCallback();
EntryDetailsParameter param = new EntryDetailsParameter(evt, control, getEntry(), getParent(), x, y);
callback.call(param);
}
}
示例4: initDrawPaneActions
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private void initDrawPaneActions() {
//Makes sure the pane doesn't scroll when using a touch screen.
drawPane.setOnScroll(event -> event.consume());
//Controls the look of the cursor, we only want the default look
drawPane.addEventHandler(InputEvent.ANY, mouseEvent -> {
getStage().getScene().setCursor(Cursor.DEFAULT);
mouseEvent.consume();
});
}
示例5: onTouchPressed
import javafx.scene.input.InputEvent; //导入依赖的package包/类
public void onTouchPressed(InputEvent event) {
Sketch sketch = new Sketch();
mController.addSketch(sketch, false, false);
double x, y;
if(event instanceof TouchEvent){
x = ((TouchEvent) event).getTouchPoint().getX();
y = ((TouchEvent) event).getTouchPoint().getY();
} else { //event instanceof mouseevent
x = ((MouseEvent)event).getX();
y = ((MouseEvent)event).getY();
}
double xPoint;
double yPoint;
if(event.getSource() instanceof AbstractNodeView){
xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + x;
yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + y;
} else {
xPoint = x;
yPoint = y;
}
sketch.setColor(color);
sketch.setStart(xPoint, yPoint);
if(event instanceof TouchEvent) {
currentSketches.put(((TouchEvent)event).getTouchPoint().getId(), sketch);
} else { //event instanceof mouseevent
currentSketch = sketch;
}
}
示例6: onTouchMoved
import javafx.scene.input.InputEvent; //导入依赖的package包/类
public void onTouchMoved(InputEvent event) {
Sketch sketch;
double xPoint;
double yPoint;
if(event instanceof TouchEvent){
sketch = currentSketches.get(((TouchEvent)event).getTouchPoint().getId());
if(event.getSource() instanceof AbstractNodeView){
xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((TouchEvent)event).getTouchPoint().getX();
yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((TouchEvent)event).getTouchPoint().getY();
} else {
xPoint = ((TouchEvent)event).getTouchPoint().getX();
yPoint = ((TouchEvent)event).getTouchPoint().getY();
}
} else { //event instanceof mouseevent
sketch = currentSketch;
if(event.getSource() instanceof AbstractNodeView){
xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((MouseEvent)event).getX();
yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((MouseEvent)event).getY();
} else {
xPoint = ((MouseEvent)event).getX();
yPoint = ((MouseEvent)event).getY();
}
}
sketch.addPoint(xPoint, yPoint);
}
示例7: init
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private void init() {
if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 ||
Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) {
if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) {
getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight());
} else {
getSkinnable().setPrefSize(PREFERRED_SIZE, PREFERRED_SIZE);
}
}
if (Double.compare(getSkinnable().getMinWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMinHeight(), 0.0) <= 0) {
getSkinnable().setMinSize(MINIMUM_SIZE, MINIMUM_SIZE);
}
if (Double.compare(getSkinnable().getMaxWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMaxHeight(), 0.0) <= 0) {
getSkinnable().setMaxSize(MAXIMUM_SIZE, MAXIMUM_SIZE);
}
inputHandler = new EventHandler<InputEvent>() {
@Override public void handle(final InputEvent EVENT) {
final EventType TYPE = EVENT.getEventType();
final Object SRC = EVENT.getSource();
if (MouseEvent.MOUSE_PRESSED == TYPE) {
if (SRC.equals(on)) {
getSkinnable().setSelected(false);
} else if (SRC.equals(off)) {
getSkinnable().setSelected(true);
}
EVENT.consume();
}
}
};
}
示例8: initTreeViews
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private void initTreeViews() {
BiConsumer<InputEvent, TreeView<String>> clickHandler = (event, treeView) -> {
if ((event instanceof MouseEvent && ((MouseEvent) event).getClickCount() == 2)
|| (event instanceof KeyEvent && ((KeyEvent) event).getCode() == KeyCode.ENTER)) {
TreeItem<String> selected = treeView.getSelectionModel().getSelectedItem();
if (selected == null) {
return;
}
if (selected.getChildren().isEmpty()) {
String className = ((IdentifiableTreeItem) selected).getId().substring(1);
if (Main.getLoadedJar() != null) {
openTab(className, selected.getValue());
}
} else {
if (event instanceof MouseEvent == selected.isExpanded()) {
selected.setExpanded(true);
while (selected.getChildren().size() == 1) {
selected = selected.getChildren().get(0);
selected.setExpanded(true);
}
} else {
selected.setExpanded(false);
}
}
}
};
obfTree.setOnMouseClicked(event -> clickHandler.accept(event, obfTree));
deobfTree.setOnMouseClicked(event -> clickHandler.accept(event, deobfTree));
obfTree.setOnKeyReleased(event -> clickHandler.accept(event, obfTree));
deobfTree.setOnKeyReleased(event -> clickHandler.accept(event, deobfTree));
}
示例9: handleKeyInput
import javafx.scene.input.InputEvent; //导入依赖的package包/类
@FXML
private void handleKeyInput(final InputEvent event) {
if (event instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent) event;
if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
showAboutDialog () ;
}
}
}
示例10: VimBar
import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
* Creates a vimbar
*/
public VimBar() {
super();
this.setOnAction(e -> {
String text = this.getText();
if(text.charAt(0) == ':') {
text = text.substring(1);
}
commandManager.parseCommand(text);
disable();
});
this.addEventHandler(KeyEvent.KEY_PRESSED,
(event) -> {
if (event.getCode() == KeyCode.ESCAPE) {
disable();
} else if (event.getCode() == KeyCode.UP) {
setText(":" + commandManager.getPrevious());
//positionCaret(getText().length());
// a weird workaround, positionCaret dosent work.
Platform.runLater(() -> positionCaret(getText().length()));
} else if (event.getCode() == KeyCode.DOWN) {
setText(":" + commandManager.getNext());
//positionCaret(getText().length());
// a weird workaround, positionCaret dosent work.
Platform.runLater(() -> positionCaret(getText().length()));
}
});
this.addEventHandler(InputEvent.ANY,
(event) -> {
if(getText().length() <= 0 || getText().charAt(0) != ':') {
disable();
}
});
}
示例11: handleKeyboardInput
import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
* Handles keyboard input (in case we ever want to add keyboard shortcuts).
*/
@FXML
public void handleKeyboardInput(InputEvent event) {
}
示例12: removeEventFilter
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private void removeEventFilter(Stage stage) {
stage.getScene().getRoot().removeEventFilter(InputEvent.ANY, JavaFxRecorderHook.this);
stage.getScene().getRoot().removeEventFilter(fileChooserEventType, JavaFxRecorderHook.this);
stage.getScene().getRoot().removeEventFilter(folderChooserEventType, JavaFxRecorderHook.this);
}
示例13: onTouchReleased
import javafx.scene.input.InputEvent; //导入依赖的package包/类
public void onTouchReleased(InputEvent event) {
if(event instanceof TouchEvent) {
currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
}
}
示例14: updateMousePosition
import javafx.scene.input.InputEvent; //导入依赖的package包/类
private static void updateMousePosition(InputEvent e) {
mouseX = ((MouseEvent) e).getX();
mouseY = ((MouseEvent) e).getY();
}
示例15: start
import javafx.scene.input.InputEvent; //导入依赖的package包/类
@Override
public void start(Stage stage) {
VBox vb = new VBox();
Scene scene = new Scene(vb);
stage.setScene(scene);
stage.setWidth(500);
stage.setHeight(480);
Pane p = new Pane();
p.setTranslateX(75);
p.setTranslateY(75);
final Text strOutput = new Text();
strOutput.setId("strOutput");
MyTextInput mti = new MyTextInput();
mti.setId("inputfield");
TextInputControl www = new TextField("bwbeb");
for (ConditionalFeature c : ConditionalFeature.values()) {
System.out.println(c);
}
EventHandler<? super InputEvent> qqq = new EventHandler<InputEvent>() {
public void handle(InputEvent e) {
System.out.println("*");
//strOutput.setText("ok"); // let it be here for debug
}
};
EventHandler<? super InputMethodEvent> qqq2 = new EventHandler<InputMethodEvent>() {
public void handle(InputMethodEvent t) {
strOutput.setText("ok");
// TODO: test all these getters listed below.
// "setOnInputMethodTextChanged" does not work now (see http://javafx-jira.kenai.com/browse/RT-12915),
// and exact values returned by getters are not documented in details, so,
// this test should be improved and expanded after RT-12915 fix.
int caretPosition = t.getCaretPosition();
String committedString = t.getCommitted();
String strRepresentation = t.toString();
ObservableList<InputMethodTextRun> lstRun =t.getComposed();
for (InputMethodTextRun run: lstRun) {
String runText = run.getText();
String runString = run.toString();
InputMethodHighlight imh = run.getHighlight();
InputMethodHighlight imh1 = InputMethodHighlight.SELECTED_RAW;
InputMethodHighlight imh2 = InputMethodHighlight.valueOf("SELECTED_RAW");
}
}
};
mti.setOnInputMethodTextChanged(qqq2);
mti.setOnKeyTyped(qqq);
www.setOnInputMethodTextChanged(qqq2);
www.setOnKeyTyped(qqq);
vb.getChildren().add(mti);
vb.getChildren().add(www);
vb.getChildren().add(strOutput);
stage.show();
}