当前位置: 首页>>代码示例>>Java>>正文


Java KeyCodes.KEY_BACKSPACE属性代码示例

本文整理汇总了Java中com.google.gwt.event.dom.client.KeyCodes.KEY_BACKSPACE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyCodes.KEY_BACKSPACE属性的具体用法?Java KeyCodes.KEY_BACKSPACE怎么用?Java KeyCodes.KEY_BACKSPACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.gwt.event.dom.client.KeyCodes的用法示例。


在下文中一共展示了KeyCodes.KEY_BACKSPACE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKey

private void onKey(KeyEvent<?> event, int charCode, int keyCode) {
  if ('0' <= charCode && charCode <= '9') {
    if (event.isAnyModifierKeyDown()) {
      event.preventDefault();
    }
  } else {
    switch (keyCode) {
      case KeyCodes.KEY_BACKSPACE:
      case KeyCodes.KEY_LEFT:
      case KeyCodes.KEY_RIGHT:
      case KeyCodes.KEY_HOME:
      case KeyCodes.KEY_END:
      case KeyCodes.KEY_TAB:
      case KeyCodes.KEY_DELETE:
        break;

      default:
        // Allow copy and paste using ctl-c/ctrl-v,
        // or whatever the platform's convention is.
        if (!(event.isControlKeyDown() || event.isMetaKeyDown() || event.isAltKeyDown())) {
          event.preventDefault();
        }
        break;
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:NpIntTextBox.java

示例2: keyToString

private static String keyToString(int code) {
  switch (code) {
    case KeyCodes.KEY_SPACE:
      return "Space";
    case KeyCodes.KEY_BACKSPACE:
      return "Backspace";
    case KeyCodes.KEY_DELETE:
      return "Del";
    case KeyCodes.KEY_INSERT:
      return "Insert";
    case KeyCodes.KEY_ENTER:
      return "Enter";
    case KeyCodes.KEY_ESCAPE:
      return "Esc";
    case KeyCodes.KEY_TAB:
      return "Tab";
    case KeyCodes.KEY_HOME:
      return "Home";
    case KeyCodes.KEY_END:
      return "End";
    case KeyCodes.KEY_PAGEUP:
      return "PageUp";
    case KeyCodes.KEY_PAGEDOWN:
      return "PageDown";
    case KeyCodes.KEY_LEFT:
      return "\u2190";
    case KeyCodes.KEY_UP:
      return "\u2191";
    case KeyCodes.KEY_RIGHT:
      return "\u2192";
    case KeyCodes.KEY_DOWN:
      return "\u2193";
    default:
      return new Character((char) code).toString();
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:EventWrapper.java

示例3: onKeyUp

public void onKeyUp(KeyUpEvent event) {
  ChartState chartInfo = getChartState(event);
  Chart chart = chartInfo.chart;

  int keyCode = event.getNativeKeyCode();
  boolean handled = true;

  if (isPageUp(keyCode)) {
    chart.pageLeft(FULL_PAGE_SCROLL);
  } else if (event.isLeftArrow() || isKeyLeft(keyCode)) {
    chart.pageLeft(HALF_PAGE_SCROLL);     
  } else if (isPageDown(keyCode)) {
    chart.pageRight(FULL_PAGE_SCROLL);
  } else if (event.isRightArrow() || isKeyRight(keyCode)) {
    chart.pageRight(HALF_PAGE_SCROLL);
  } else if (event.isUpArrow() || isNextZoom(keyCode)) {
    chart.nextZoom();
    ChartKeyDownHandler.UP_NUM = 0;
  } else if (event.isDownArrow() || isPrevZoom(keyCode)) {
    chart.prevZoom();
    ChartKeyDownHandler.DOWN_NUM = 0;
  } else if (keyCode == KeyCodes.KEY_BACKSPACE) {
    History.back();
  } else if (isMaxZoomOut(keyCode)) {
    chart.maxZoomOut();
  } else {
    handled = false;
  }
  
  chartInfo.setHandled(handled);
  if (handled) {
     event.stopPropagation();
     event.preventDefault();
  }

}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:36,代码来源:ChartKeyUpHandler.java

示例4: onKeyUp

@Override
public void onKeyUp(KeyUpEvent event) {
	if (isReadOnly() || !isEnabled()) {
		return;
	}

	int keyCode = event.getNativeEvent().getKeyCode();

	boolean processed = false;

	switch (keyCode) {
	case KeyCodes.KEY_LEFT:
	case KeyCodes.KEY_RIGHT:
	case KeyCodes.KEY_BACKSPACE:
	case KeyCodes.KEY_DELETE:
	case KeyCodes.KEY_TAB:
		if (getText().isEmpty()) {
			setValue(formatValue(min));
		}
		return;
	case KeyCodes.KEY_UP:
		if (step != 0) {
			increaseValue();
			processed = true;
		}
		break;
	case KeyCodes.KEY_DOWN:
		if (step != 0) {
			decreaseValue();
			processed = true;
		}
		break;
	}

	if (processed) {
		cancelKey();
	}
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:38,代码来源:ValueTextBox.java

示例5: onKeyPress

@Override
public void onKeyPress(KeyPressEvent event) {

	if (isReadOnly() || !isEnabled()) {
		return;
	}

	int keyCode = event.getNativeEvent().getKeyCode();

	switch (keyCode) {
	case KeyCodes.KEY_LEFT:
	case KeyCodes.KEY_RIGHT:
	case KeyCodes.KEY_BACKSPACE:
	case KeyCodes.KEY_DELETE:
	case KeyCodes.KEY_TAB:
	case KeyCodes.KEY_UP:
	case KeyCodes.KEY_DOWN:
		return;
	}

	int index = getCursorPos();
	String previousText = getText();
	String newText;
	if (getSelectionLength() > 0) {
		newText = previousText.substring(0, getCursorPos())
				+ event.getCharCode()
				+ previousText.substring(
						getCursorPos() + getSelectionLength(),
						previousText.length());
	} else {
		newText = previousText.substring(0, index) + event.getCharCode()
				+ previousText.substring(index, previousText.length());
	}
	cancelKey();

	setValue(newText, true);
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:37,代码来源:ValueTextBox.java

示例6: createCurPageBox

/**
* Create a box that holds the current page.
*/
private void createCurPageBox() {
    // Setup the widget
    curPageBox.setWidth("3em");
    curPageBox.setText("1");
    curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);

    // Disallow non-numeric pages
    KeyPressHandler handler = new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            char charCode = event.getCharCode();
            if (charCode == KeyCodes.KEY_ENTER) {
                PagingOptions.this.imageGridPanel.getImageGrid().gotoPage(getPagingBoxValue(), false);
            } else if (!Character.isDigit(charCode)
                    && (charCode != KeyCodes.KEY_TAB)
                    && (charCode != KeyCodes.KEY_BACKSPACE)
                    && (charCode != KeyCodes.KEY_DELETE)
                    && (charCode != KeyCodes.KEY_ENTER)
                    && (charCode != KeyCodes.KEY_HOME)
                    && (charCode != KeyCodes.KEY_END)
                    && (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP)
                    && (charCode != KeyCodes.KEY_RIGHT)
                    && (charCode != KeyCodes.KEY_DOWN)) {
                curPageBox.cancelKey();
            }
        }
    };

    // Add the handler
    curPageBox.addKeyPressHandler(handler);
}
 
开发者ID:lsst,项目名称:firefly,代码行数:33,代码来源:PagingOptions.java

示例7: handleEvent

public void handleEvent(NativeEvent event) {
  int code = event.getKeyCode();

  NativeEvent e = event;

  String type = event.getType();

  if ("keydown".equals(type) && keyEvent == Event.ONKEYDOWN
      || "keypress".equals(type) && keyEvent == Event.ONKEYPRESS) {

  } else {
    return;
  }

  if (component != null && component.getElement() != e.getCurrentEventTarget().cast()) {
    return;
  }

  if (preventDefault) {
    event.preventDefault();
  }

  onKeyPress(e);

  switch (code) {
    case KeyCodes.KEY_ALT:
      onAlt(e);
      break;
    case KeyCodes.KEY_BACKSPACE:
      onBackspace(e);
      break;
    case KeyCodes.KEY_CTRL:
      onControl(e);
      break;
    case KeyCodes.KEY_DELETE:
      onDelete(e);
      break;
    case KeyCodes.KEY_DOWN:
      onDown(e);
      break;
    case KeyCodes.KEY_END:
      onEnd(e);
      break;
    case KeyCodes.KEY_ENTER:
      onEnter(e);
      break;
    case KeyCodes.KEY_ESCAPE:
      onEsc(e);
      break;
    case KeyCodes.KEY_HOME:
      onHome(e);
      break;
    case KeyCodes.KEY_LEFT:
      onLeft(e);
      break;
    case KeyCodes.KEY_PAGEDOWN:
      onPageDown(e);
      break;
    case KeyCodes.KEY_PAGEUP:
      onPageUp(e);
      break;
    case KeyCodes.KEY_SHIFT:
      onShift(e);
      break;
    case KeyCodes.KEY_TAB:
      onTab(e);
      break;
    case KeyCodes.KEY_RIGHT:
      onRight(e);
      break;
    case KeyCodes.KEY_UP:
      onUp(e);
      break;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:75,代码来源:KeyboardNavigationHandler.java

示例8: onKeyPress

@Override
public void onKeyPress(KeyPressEvent event) {
  final char code = event.getCharCode();
  final int nativeCode = event.getNativeEvent().getKeyCode();
  switch (nativeCode) {
    case KeyCodes.KEY_ALT:
    case KeyCodes.KEY_BACKSPACE:
    case KeyCodes.KEY_CTRL:
    case KeyCodes.KEY_DELETE:
    case KeyCodes.KEY_DOWN:
    case KeyCodes.KEY_END:
    case KeyCodes.KEY_ENTER:
    case KeyCodes.KEY_ESCAPE:
    case KeyCodes.KEY_HOME:
    case KeyCodes.KEY_LEFT:
    case KeyCodes.KEY_PAGEDOWN:
    case KeyCodes.KEY_PAGEUP:
    case KeyCodes.KEY_RIGHT:
    case KeyCodes.KEY_SHIFT:
    case KeyCodes.KEY_TAB:
    case KeyCodes.KEY_UP:
      // Allow these, even if one of their assigned codes is
      // identical to an ASCII character we do not want to
      // allow in the box.
      //
      // We still want to let the user move around the input box
      // with their arrow keys, or to move between fields using tab.
      // Invalid characters introduced will be caught through the
      // server's own validation of the input data.
      //
      break;

    default:
      final TextBox box = (TextBox) event.getSource();
      final String re;
      if (box.getCursorPos() == 0) {
        re = Account.USER_NAME_PATTERN_FIRST;
      } else {
        re = Account.USER_NAME_PATTERN_REST;
      }
      if (!String.valueOf(code).matches("^" + re + "$")) {
        event.preventDefault();
        event.stopPropagation();
      }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:46,代码来源:UsernameField.java


注:本文中的com.google.gwt.event.dom.client.KeyCodes.KEY_BACKSPACE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。