javafx.scene.input.KeyEvent.consume()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中javafx.scene.input.KeyEvent.consume()方法的一些代码示例,展示了KeyEvent.consume()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.consume()方法的具体详情如下:
包路径:javafx.scene.input.KeyEvent
类名称:KeyEvent
方法名:consume

KeyEvent.consume介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

private void initNavigation() {
  setOnKeyPressed(ke -> {
    switch (ke.getCode()) {
      case SPACE:
      case ENTER:
        // select the focused color
        if (focusedSquare != null) {
          focusedSquare.selectColor(ke);
        }
        ke.consume();
        break;
      default: // no-op
    }
  });
}

代码示例来源:origin: jfoenixadmin/JFoenix

public void selectColor(KeyEvent event) {
    if (rectangle.getFill() != null) {
      if (rectangle.getFill() instanceof Color) {
        colorPicker.setValue((Color) rectangle.getFill());
        colorPicker.fireEvent(new ActionEvent());
      }
      event.consume();
    }
    colorPicker.hide();
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

event.consume();
break;
event.consume();
break;
  default:
    editor.fireEvent(ke.copyFor(editor, editor));
    ke.consume();

代码示例来源:origin: pmd/pmd

autoCompletePopup.getItems().get(focusIdx).getOnAction().handle(new ActionEvent());
  e.consume();
});

代码示例来源:origin: jfoenixadmin/JFoenix

if (keyEvent.getCode() == KeyCode.ESCAPE) {
  if (!isHideOnEscape()) {
    keyEvent.consume();

代码示例来源:origin: jfoenixadmin/JFoenix

event.consume();
  break;
case PAGE_UP:
    forward(-1, MONTHS, true, true);
  event.consume();
  break;
case PAGE_DOWN:
    forward(1, MONTHS, true, true);
  event.consume();
  break;
case ESCAPE:
  datePicker.hide();
  event.consume();
  break;
case F4:
  break;
default:
  event.consume();

代码示例来源:origin: org.controlsfx/controlsfx

@Override
  public void handle(KeyEvent event) {
    event.consume();
  }
});

代码示例来源:origin: com.vektorsoft.demux.desktop/demux-jfx-core

@Override
  public void handle(KeyEvent t) {
    t.consume();
  }
};

代码示例来源:origin: torakiki/pdfsam

textField.setText(converter.toString(getItem()));
  cancelEdit();
  event.consume();
} else if (event.getCode() == KeyCode.RIGHT) {
  getTableView().getSelectionModel().selectRightCell();
  event.consume();
} else if (event.getCode() == KeyCode.LEFT) {
  getTableView().getSelectionModel().selectLeftCell();
  event.consume();
} else if (event.getCode() == KeyCode.UP) {
  getTableView().getSelectionModel().selectAboveCell();
  event.consume();
} else if (event.getCode() == KeyCode.DOWN) {
  getTableView().getSelectionModel().selectBelowCell();
  event.consume();

代码示例来源:origin: com.jfoenix/jfoenix

private void initNavigation() {
  setOnKeyPressed(ke -> {
    switch (ke.getCode()) {
      case SPACE:
      case ENTER:
        // select the focused color
        if (focusedSquare != null) {
          focusedSquare.selectColor(ke);
        }
        ke.consume();
        break;
      default: // no-op
    }
  });
}

代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX

@Override
public void handle(KeyEvent event) {
  if (event.getCode().equals(KeyCode.Q) && event.isControlDown()) {
    event.consume();
    Platform.exit();
  }
  
}

代码示例来源:origin: com.powsybl/powsybl-gse-security-analysis

public void handle(final KeyEvent keyEvent) {
    if (copyKeyCodeCompination.match(keyEvent) && keyEvent.getSource() instanceof TableView) {
      // copy to clipboard
      copySelectionToClipboard((TableView<?>) keyEvent.getSource(), copyHeaders);
      // event is handled, consume it
      keyEvent.consume();
    }
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.workbench.fx

void processKeyEvent(@NonNull List<@NonNull KeyStroke> keyStrokes, @NonNull KeyEvent event) {
  // Dispatch the keyboard shortcut, if any.
  boolean eatKey = false;
  if (!keyStrokes.isEmpty()) {
    eatKey = press(keyStrokes, event);
  }
  if (eatKey) {
    event.consume();
    // switch (event.type) {
    // case SWT.KeyDown:
    // event.doit = false;
    // break;
    // case SWT.Traverse:
    // event.detail = SWT.TRAVERSE_NONE;
    // event.doit = true;
    // break;
    // default:
    // }
    // event.type = SWT.NONE;
  }
}

代码示例来源:origin: org.tentackle/tentackle-fx

@Override
protected void filterKeys(T control) {
 super.filterKeys(control);
 if (control instanceof FxComponent) {
  control.addEventFilter(KeyEvent.ANY, event -> {
   if (!control.isEditable() && ((FxComponent) control).getTableCell() != null) {
    // don't allow to navigate within the cells of a table if combobox is used as an editor
    // @todo: verify if still necessary in newer versions than java 9
    switch (event.getCode()) {
     case PAGE_DOWN:
     case PAGE_UP:
     case HOME:
     case END:
     case LEFT:
     case RIGHT:
      event.consume();
    }
   }
  });
 }
}

代码示例来源:origin: com.jfoenix/jfoenix

public void selectColor(KeyEvent event) {
    if (rectangle.getFill() != null) {
      if (rectangle.getFill() instanceof Color) {
        colorPicker.setValue((Color) rectangle.getFill());
        colorPicker.fireEvent(new ActionEvent());
      }
      event.consume();
    }
    colorPicker.hide();
  }
}

代码示例来源:origin: org.tentackle/tentackle-fx

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setType(Class<?> type) {
 super.setType(type);
 // choice box does not need a value translator because the items are already of model type
 // and choice-box is not editable
 // deselect by DELETE- or BACKSPACE-key (with or without shift)
 component.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
  if (!event.isAltDown() && !event.isControlDown() && !event.isMetaDown() && !event.isShortcutDown() &&
    (event.getCode() == KeyCode.DELETE || event.getCode() == KeyCode.BACK_SPACE) &&
    !component.isDisabled() && isDeselectAllowed()) {
   
   event.consume();
   component.getSelectionModel().clearSelection();
  }
 });
 if (type.isEnum()) {
  ObservableList items = component.getItems();
  items.clear();
  items.addAll(Arrays.asList(type.getEnumConstants()));
 }
}

代码示例来源:origin: org.tentackle/tentackle-fx

@Override
@SuppressWarnings("unchecked")
public void setType(Class<?> type) {
 // important to set the type before creating the translator,
 // since the translator may need to know the type
 super.setType(type);
 // deselect by DELETE- or BACKSPACE-key (with or without shift)
 component.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
  if (!event.isAltDown() && !event.isControlDown() && !event.isMetaDown() && !event.isShortcutDown() &&
    (event.getCode() == KeyCode.DELETE || event.getCode() == KeyCode.BACK_SPACE) &&
    !component.isEditable() && !component.isDisabled() && isDeselectAllowed()) {
   
   event.consume();
   component.getSelectionModel().clearSelection();
  }
 });
 if (type.isEnum()) {
  ObservableList items = component.getItems();
  items.clear();
  items.addAll(Arrays.asList(type.getEnumConstants()));
 }
}

代码示例来源:origin: no.tornado/tornadofx-controls

private void createDatePicker() {
  datePicker = new DatePicker(getItem());
  datePicker.converterProperty().bind(converterProperty());
  datePicker.setOnAction(event -> {
    commitEdit(datePicker.getValue());
    event.consume();
  });
  datePicker.setOnKeyReleased(t -> {
    if (t.getCode() == KeyCode.ESCAPE) {
      cancelEdit();
      t.consume();
    }
  });
}

代码示例来源:origin: org.tentackle/tentackle-fx

@Override
public void configure(T control) {
 super.configure(control);
 // first keystroke triggers check for modification
 control.textProperty().addListener(o -> ((FxComponent) control).triggerViewModified());
 // Shift-Backspace clears the field
 control.addEventFilter(KeyEvent.ANY, (KeyEvent event) -> {
  if (event.getCode() == KeyCode.BACK_SPACE && event.isShiftDown() &&
    !event.isControlDown() && !event.isAltDown() && !event.isMetaDown()) {
   if (event.getEventType() == KeyEvent.KEY_PRESSED &&
     !control.isDisabled() && control.isEditable()) {
    control.clear();
   }
   event.consume();
  }
 });
}

代码示例来源:origin: org.tentackle/tentackle-fx

@Override
public void configure(T control) {
 super.configure(control);
 // first keystroke triggers check for modification
 control.getEditor().textProperty().addListener(o -> ((FxComponent) control).triggerViewModified());
 // Shift-Backspace clears the field
 control.addEventFilter(KeyEvent.ANY, (KeyEvent event) -> {
  if (event.getCode() == KeyCode.BACK_SPACE && event.isShiftDown() &&
    !event.isControlDown() && !event.isAltDown() && !event.isMetaDown()) {
   if (event.getEventType() == KeyEvent.KEY_PRESSED &&
     !control.getEditor().isDisabled() && control.getEditor().isEditable()) {
    control.getEditor().clear();
   }
   event.consume();
  }
 });
}

相关文章