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


Java KeyCodes类代码示例

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


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

示例1: addEnterTarget

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
/**
 * Adds a {@link KeyPressHandler} to the specified widget which calls {@link Button#click()} on <code>targetButton</code>
 * when the Enter key is pressed.
 * @param widget       widget to add the key handler to
 * @param targetButton target button to activate when the enter key is pressed
 */
public static void addEnterTarget( final HasKeyPressHandlers widget, final Button targetButton ) {
	widget.addKeyPressHandler( new KeyPressHandler() {
		@Override
		public void onKeyPress( final KeyPressEvent event ) {
			if ( event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER )
				targetButton.click();
		}
	} );
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:16,代码来源:ClientUtils.java

示例2: configure

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Override
public EntitiesExplorerView configure(final String entityType,
                                      final EntitiesList.View entitiesListView) {
    this.entitiesListView = entitiesListView;
    this.entityType = entityType;

    initWidget(uiBinder.createAndBindUi(this));
    searchBox.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                doSearch(searchBox.getText());
            }
        }
    });
    searchButton.addClickHandler(e -> doSearch(searchBox.getText()));

    clearSearchButton.addDomHandler(new ClickHandler() {
                                        @Override
                                        public void onClick(final ClickEvent clickEvent) {
                                            doSearch("");
                                        }
                                    },
                                    ClickEvent.getType());
    clearSearch();
    return this;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:29,代码来源:EntitiesExplorerViewImpl.java

示例3: setEscapeHandler

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
private KeyUpHandler setEscapeHandler() {
	KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode()) {
				for (Control control : controls) {
					try {
						((DrawFeature) control).cancel();
					} catch (Exception e) {
						LOGGER.error("ACTION CANCELED: "
								+ control.getControlId());
					}
				}
			}
		}
	};
	return handler;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:19,代码来源:ToggleTool.java

示例4: setUndoHandler

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
private KeyUpHandler setUndoHandler() {
	final KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_U == event.getNativeEvent().getKeyCode()) {
				for (final Control control : controls) {
					try {
						((DrawFeature) control).undo();
					} catch (Exception e) {
						LOGGER.error(
								"ACTION UNDO: " + control.getControlId(), e);
					}
				}
			}
		}
	};
	return handler;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:19,代码来源:ToggleTool.java

示例5: setRedoHandler

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
private KeyUpHandler setRedoHandler() {
	final KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_R == event.getNativeEvent().getKeyCode()) {
				for (final Control control : controls) {
					try {
						((DrawFeature) control).redo();
					} catch (Exception e) {
						LOGGER.error("ACTION REDO: "
								+ control.getControlId());
					}
				}
			}
		}
	};
	return handler;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:19,代码来源:ToggleTool.java

示例6: onKeyDown

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent keyDownEvent) {

    if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {

        SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class);

        if (panel != null) {
            WidgetUtil.focus(panel.getParent().getElement());

            // prevent further bubbling of the event as it has only
            // navigational purpose if thrown at this depth. A subsequent
            // press of ESC is not stopped, so ESC abort actions of the
            // application should work as soon as the focus is in
            // "navigational mode" on a grid-cell
            keyDownEvent.preventDefault();
            keyDownEvent.stopPropagation();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:EscKeyDownHandler.java

示例7: onEventPreview

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Override
public boolean onEventPreview(Event event) {
    int type = DOM.eventGetType(event);

    if ((type == Event.ONCLICK || type == Event.ONTOUCHEND)
            && event.getEventTarget() != null) {
        Element target = Element.as(event.getEventTarget());
        if (target.getClassName() != null && target.getClassName().contains(CUBA_NOTIFICATION_MODALITY_CURTAIN)) {
            hide();
            return false;
        }
    }

    if (type == Event.ONKEYDOWN && event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
        if (!getElement().getClassName().contains(TRAY_STYLE)) {
            hide();
            return false;
        }
    }

    return super.onEventPreview(event);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:CubaNotification.java

示例8: shouldTrackCursor

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Override
public boolean shouldTrackCursor() {
  if (isMouseButtonEvent()) {
    return true;
  }
  if (isKeyEvent()) {
    KeySignalType keySignalType = getKeySignalType();
    // The cursor location should move if the user either has modified the
    // content (typed or delete), or move the cursor deliberately.  However, page up/down
    // doesn't actually move the cursor, so we don't want to move the view port
    int keyCode = getKeyCode();
    return keySignalType == KeySignalType.INPUT ||
          keySignalType == KeySignalType.DELETE ||
          keySignalType == KeySignalType.NAVIGATION && (
             keyCode != KeyCodes.KEY_PAGEDOWN &&
             keyCode != KeyCodes.KEY_PAGEUP);
  }
  return false;    
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:EditorEventImpl.java

示例9: handleEventsManuallyOnNode

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
private boolean handleEventsManuallyOnNode(EditorEvent event, Point<ContentNode> caret)
    throws SelectionLostException {
  // Note that caret may be null if this is called during typing extraction

  // Always handle enter specially, and always cancel the default action.
  // TODO(danilatos): This is still a slight anomaly, to call a
  // node.handleXYZ method here.
  if (event.isOnly(KeyCodes.KEY_ENTER)) {
    refreshEditorWithCaret(event);
    caret = event.getCaret().asPoint();
    editorInteractor.checkpoint(new FocusedContentRange(caret));
    router.handleEnter(caret.getContainer(), event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return true;
  } else if (event.isCombo(KeyCodes.KEY_ENTER, KeyModifier.SHIFT)) {
    // shift+enter inserts a "newline" (such as a <br/>) by default
    // TODO(danilatos): Form elements want to handle this.
    return true;
  }
  return false;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:EditorEventHandler.java

示例10: handleNavigationKeyEvents

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
private boolean handleNavigationKeyEvents(EditorEvent event) {
  editorInteractor.checkpoint(null);
  editorInteractor.clearCaretAnnotations();
  ContentNode node = cachedSelection.getFocus().getContainer();
  logger.trace().log("Navigation event");

  // Not using key combo, because we want to handle left key with
  // any modifiers also applying.
  // TODO(danilatos): MoveUnit, and holding down shift for selection.
  if (event.getKeyCode() == KeyCodes.KEY_LEFT) {
    router.handleLeft(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_RIGHT);
    return !event.shouldAllowBrowserDefault();
  } else if (event.getKeyCode() == KeyCodes.KEY_RIGHT) {
    router.handleRight(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return !event.shouldAllowBrowserDefault();
  } else {
    editorInteractor.rebiasSelection(CursorDirection.NEUTRAL);
  }
  return false;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:EditorEventHandler.java

示例11: testDeleteWithRangeSelectedDeletesRange

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
public void testDeleteWithRangeSelectedDeletesRange() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.DELETE, KeyCodes.KEY_LEFT);

  //Event event = Document.get().createKeyPressEvent(
  //    false, false, false, false, KeyCodes.KEY_BACKSPACE, 0).cast();

  Text input = Document.get().createTextNode("ABCDE");
  ContentNode node = new ContentTextNode(input, null);

  final Point<ContentNode> start = Point.inText(node, 1);
  final Point<ContentNode> end = Point.inText(node, 4);
  FakeEditorInteractor interactor = setupFakeEditorInteractor(
      new FocusedContentRange(start, end));
  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.DELETE_RANGE).nOf(1).withArgs(
      start, end, false).returns(start);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:EditorEventHandlerGwtTest.java

示例12: onPreviewNativeEvent

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Override
protected void onPreviewNativeEvent(NativePreviewEvent preview) {
	super.onPreviewNativeEvent(preview);

	NativeEvent evt = preview.getNativeEvent();
	if (evt.getType().equals("keydown")) {
		// Use the popup's key preview hooks to close the dialog when either
		// enter or escape is pressed.
		switch (evt.getKeyCode()) {
		case KeyCodes.KEY_ENTER:
		case KeyCodes.KEY_ESCAPE:
			hide();
			break;
		default:
			break;
		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:AboutDialog.java

示例13: handleTabKey

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
/**
 * Handles TAB key and Shift-TAB key presses.
 */
protected boolean handleTabKey(Event event, ChartState chartInfo, int keyCode,
    boolean isShiftKeyDown) {
  if (DOM.eventGetType(event) != chartInfo.getTabKeyEventCode()) {
    return false;
  }

  if (keyCode == KeyCodes.KEY_TAB) {
    if (isShiftKeyDown) {
      chartInfo.chart.prevFocus();
    } else {
      chartInfo.chart.nextFocus();
    }
    return true;
  }

  return false;
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:21,代码来源:AbstractEventHandler.java

示例14: enterKeyEditsCells

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
@Test
public void enterKeyEditsCells() {
    when(layer.getGridWidgets()).thenReturn(gridWidgets);
    when(gridWidget1.isSelected()).thenReturn(true);
    when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER);

    gridWidget1Data.selectCell(0,
                               0);

    handler.onKeyDown(event);

    verify(gridWidget1,
           times(1)).startEditingCell(eq(0),
                                      eq(0));
    verify(layer,
           never()).draw();
    verify(keyboardOperationEditCell,
           times(1)).perform(eq(gridWidget1),
                             eq(false),
                             eq(false));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:22,代码来源:BaseGridWidgetKeyboardHandlerTest.java

示例15: onKeyPress

import com.google.gwt.event.dom.client.KeyCodes; //导入依赖的package包/类
public void onKeyPress(KeyPressEvent event) {
  ChartState chartInfo = getChartState(event);

  Chart chart = chartInfo.chart;

  int keyCode = event.getCharCode();
  boolean handled = true;
  if (keyCode == KeyCodes.KEY_TAB) {
    handled = handleTabKey((Event)event.getNativeEvent(), chartInfo, keyCode, event.isShiftKeyDown());
  } else if (keyCode == KEY_Z) {
    chart.nextZoom();
  } else if (keyCode == KEY_X) {
    chart.prevZoom();
  } else if (keyCode == KeyCodes.KEY_ENTER) {
    chart.maxZoomToFocus();
  } else {
    handled = false;
  }

  chartInfo.setHandled(handled);
  if (handled) {
      event.stopPropagation();
      event.preventDefault();
  }
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:26,代码来源:ChartKeyPressHandler.java


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