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

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

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

KeyEvent.getEventType介绍

暂无

代码示例

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

e.getEventType().equals(KeyEvent.KEY_RELEASED) && e.getCode() == KeyCode.ENTER
  || e.getEventType().equals(KeyEvent.KEY_PRESSED) && e.getCode() == KeyCode.TAB

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

/**
 * Handle key event
 *
 * @param arg0
 *            the event
 */
protected void callActionForEvent(KeyEvent arg0) {
  if (arg0.getEventType() == KeyEvent.KEY_PRESSED) {
    _keyPressed(arg0);
  } else if (arg0.getEventType() == KeyEvent.KEY_TYPED) {
    _keyTyped(arg0);
  }
}

代码示例来源:origin: org.processing/core

@SuppressWarnings("deprecation")
private int getKeyCode(KeyEvent fxEvent) {
 if (fxEvent.getEventType() == KeyEvent.KEY_TYPED) {
  return 0;
 }
 KeyCode kc = fxEvent.getCode();
 switch (kc) {
  case ALT_GRAPH:
   return PConstants.ALT;
  default:
   break;
 }
 return kc.impl_getCode();
}

代码示例来源:origin: org.processing/core

if (fxEvent.getEventType() == KeyEvent.KEY_TYPED) {
 ch = fxEvent.getCharacter();
} else {

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

@Override
protected void remapKeys(T control) {
 control.addEventFilter(KeyEvent.ANY, (KeyEvent event) -> {
  if (event.getCode() == KeyCode.ENTER &&
    !event.isControlDown() && !event.isAltDown() && !event.isMetaDown() &&
    event.getEventType() == KeyEvent.KEY_PRESSED) {
   if (event.isShiftDown()) {
    focusPrevious(control);
   }
   else {
    focusNext(control);
   }
  }
 });
}

代码示例来源:origin: org.processing/core

protected void fxKeyEvent(javafx.scene.input.KeyEvent fxEvent) {
 int action = 0;
 EventType<? extends KeyEvent> et = fxEvent.getEventType();
 if (et == KeyEvent.KEY_PRESSED) {
  action = processing.event.KeyEvent.PRESS;
 } else if (et == KeyEvent.KEY_RELEASED) {
  action = processing.event.KeyEvent.RELEASE;
 } else if (et == KeyEvent.KEY_TYPED) {
  action = processing.event.KeyEvent.TYPE;
 }
 int modifiers = 0;
 if (fxEvent.isShiftDown()) {
  modifiers |= processing.event.Event.SHIFT;
 }
 if (fxEvent.isControlDown()) {
  modifiers |= processing.event.Event.CTRL;
 }
 if (fxEvent.isMetaDown()) {
  modifiers |= processing.event.Event.META;
 }
 if (fxEvent.isAltDown()) {
  modifiers |= processing.event.Event.ALT;
 }
 long when = System.currentTimeMillis();
 char keyChar = getKeyChar(fxEvent);
 int keyCode = getKeyCode(fxEvent);
 sketch.postEvent(new processing.event.KeyEvent(fxEvent, when,
                         action, modifiers,
                         keyChar, keyCode));
}

代码示例来源:origin: org.jrebirth.af/core

/**
   * {@inheritDoc}
   */
  @Override
  public void handle(final KeyEvent keyEvent) {

    final EventType<?> type = keyEvent.getEventType();

    if (KeyEvent.KEY_PRESSED == type) {
      adapter().keyPressed(keyEvent);
    } else if (KeyEvent.KEY_RELEASED == type) {
      adapter().keyReleased(keyEvent);
    } else if (KeyEvent.KEY_TYPED == type) {
      adapter().keyTyped(keyEvent);
    } else {
      adapter().key(keyEvent);
    }

  }
}

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

/**
 * The event
 *
 * @param source
 *            the source
 * @param target
 *            the target
 * @param event
 *            the key
 */
public VerifyEvent(Object source, EventTarget target, KeyEvent event) {
  super(source, target, VERIFY);
  boolean isKeyTyped = event.getEventType() == KeyEvent.KEY_TYPED;
  this.character = isKeyTyped ? event.getCharacter() : KeyEvent.CHAR_UNDEFINED;
  this.text = isKeyTyped ? "" : event.getText(); //$NON-NLS-1$
  this.code = isKeyTyped ? KeyCode.UNDEFINED : event.getCode();
  this.shiftDown = event.isShiftDown();
  this.controlDown = event.isControlDown();
  this.altDown = event.isAltDown();
  this.metaDown = event.isMetaDown();
}

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

/**
 * The event
 * 
 * @param source
 *            the source
 * @param target
 *            the target
 * @param event
 *            the key
 */
public VerifyEvent(Object source, EventTarget target, KeyEvent event) {
  super(source, target, VERIFY);
  boolean isKeyTyped = event.getEventType() == KeyEvent.KEY_TYPED;
  this.character = isKeyTyped ? event.getCharacter() : KeyEvent.CHAR_UNDEFINED;
  this.text = isKeyTyped ? "" : event.getText(); //$NON-NLS-1$
  this.code = isKeyTyped ? KeyCode.UNDEFINED : event.getCode();
  this.shiftDown = event.isShiftDown();
  this.controlDown = event.isControlDown();
  this.altDown = event.isAltDown();
  this.metaDown = event.isMetaDown();
}

代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit

@Override
  public void handle(KeyEvent event)
  {
   double modifier;
   if (fastModifierPredicate.get() == null || !fastModifierPredicate.get().test(event))
     modifier = slowModifier.get();
   else
     modifier = fastModifier.get();
   if (currentZoom != null)
   {
     modifier *= Math.pow(Math.abs(currentZoom.get()), zoomToTranslationPow.get());
     modifier = Math.min(modifier, minTranslationOffset.get());
   }
   KeyCode keyDown = event.getCode();
   boolean isKeyReleased = event.getEventType() == KeyEvent.KEY_RELEASED;
   if (keyDown == forwardKey.get())
     activeTranslationOffset.setZ(isKeyReleased ? 0.0 : modifier);
   if (keyDown == backwardKey.get())
     activeTranslationOffset.setZ(isKeyReleased ? 0.0 : -modifier);
   if (keyDown == rightKey.get())
     activeTranslationOffset.setX(isKeyReleased ? 0.0 : modifier);
   if (keyDown == leftKey.get())
     activeTranslationOffset.setX(isKeyReleased ? 0.0 : -modifier);
   if (keyDown == downKey.get())
     activeTranslationOffset.setY(isKeyReleased ? 0.0 : modifier);
   if (keyDown == upKey.get())
     activeTranslationOffset.setY(isKeyReleased ? 0.0 : -modifier);
  }
};

代码示例来源:origin: us.ihmc/IHMCJavaFXToolkit

@Override
  public void handle(KeyEvent event)
  {
   double modifier;
   if (fastModifierPredicate.get() == null || !fastModifierPredicate.get().test(event))
     modifier = slowModifier.get();
   else
     modifier = fastModifier.get();
   if (currentZoom != null)
   {
     modifier *= Math.pow(Math.abs(currentZoom.get()), zoomToTranslationPow.get());
     modifier = Math.min(modifier, minTranslationOffset.get());
   }
   KeyCode keyDown = event.getCode();
   boolean isKeyReleased = event.getEventType() == KeyEvent.KEY_RELEASED;
   if (keyDown == forwardKey.get())
     activeTranslationOffset.setZ(isKeyReleased ? 0.0 : modifier);
   if (keyDown == backwardKey.get())
     activeTranslationOffset.setZ(isKeyReleased ? 0.0 : -modifier);
   if (keyDown == rightKey.get())
     activeTranslationOffset.setX(isKeyReleased ? 0.0 : modifier);
   if (keyDown == leftKey.get())
     activeTranslationOffset.setX(isKeyReleased ? 0.0 : -modifier);
   if (keyDown == downKey.get())
     activeTranslationOffset.setY(isKeyReleased ? 0.0 : modifier);
   if (keyDown == upKey.get())
     activeTranslationOffset.setY(isKeyReleased ? 0.0 : -modifier);
  }
};

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

/**
 * Filters certain keys for special features.
 *
 * @param control the fx control
 */
public void filterKeys(Control control) {
 if (control instanceof FxComponent) {
  control.addEventFilter(KeyEvent.ANY, event -> {
   if (event.getCode() == KeyCode.Z && event.isControlDown() &&
     !event.isAltDown() && !event.isMetaDown() && !event.isShiftDown()) {
    FxComponent comp = (FxComponent) control;
    if (comp.isViewModified()) {
     if (event.getEventType() == KeyEvent.KEY_PRESSED) {
      // Ctrl-Z pressed and old view value saved: restore it!
      comp.setViewObject(comp.getSavedViewObject());
     }
     event.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
protected void remapKeys(T control) {
 control.addEventFilter(KeyEvent.ANY, (KeyEvent event) -> {
  if ((event.getCode() == KeyCode.TAB || event.getCode() == KeyCode.ENTER) &&
    !event.isAltDown() && !event.isMetaDown()) {
   if (event.getEventType() == KeyEvent.KEY_PRESSED) {
    if (event.isControlDown()) {
     control.insertText(control.getCaretPosition(), event.getCode() == KeyCode.TAB ? "\t" : "\n");
    }
    else {
     if (event.isShiftDown()) {
      focusPrevious(control);
     }
     else {
      focusNext(control);
     }
    }
   }
   event.consume();
  }
 });
}

代码示例来源:origin: eu.mihosoft.vrl.jcsg/jcsg

if (t.getEventType() == KeyEvent.KEY_PRESSED) {
  if (t.getCode() == modifier) {
    anchor = property.getValue();
} else if (t.getEventType() == KeyEvent.KEY_RELEASED) {
  if (t.getCode() != modifier && isModifierCorrect(t, modifier)) {
    anchor = property.getValue();

代码示例来源: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();
  }
 });
}

相关文章