本文整理汇总了Java中com.google.gwt.event.dom.client.KeyDownEvent类的典型用法代码示例。如果您正苦于以下问题:Java KeyDownEvent类的具体用法?Java KeyDownEvent怎么用?Java KeyDownEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyDownEvent类属于com.google.gwt.event.dom.client包,在下文中一共展示了KeyDownEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: injectEvents
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void injectEvents(HandlerManager eventBus) {
// TODO Auto-generated method stub
eventBus.addHandler(RVKeyDownEvent.type, new RVKeyDownEventHandler() {
@Override
public void onKeyDown(RVKeyDownEvent event) {
KeyDownEvent keyDownEvent = event.getEvent();
if (keyDownEvent.isControlKeyDown() && keyDownEvent.isShiftKeyDown()
&& keyDownEvent.getNativeEvent().getKeyCode() == 39) {
// Ctrl + Shift + ->
keyDownEvent.getNativeEvent().preventDefault();
nextBatchPage();
}
}
});
}
示例2: configure
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的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;
}
示例3: VImageViewer
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
public VImageViewer() {
/* Create widget's root panel */
panelRoot = new FlowPanel();
Style style = panelRoot.getElement().getStyle();
style.setPosition(Position.RELATIVE);
setStyleName(CLASSNAME);
panelRoot.setStyleName(CLASSNAME + "-flow");
style.setWidth(100, Unit.PCT);
style.setHeight(100, Unit.PCT);
/* Create image container */
imageContainer = new FlowPanel();
style = imageContainer.getElement().getStyle();
style.setPosition(Position.ABSOLUTE);
style.setOverflow(Overflow.HIDDEN);
/* Add widgets */
setWidget(panelRoot);
panelRoot.add(imageContainer);
/* Register handlers */
addDomHandler(this, KeyDownEvent.getType());
addDomHandler(this, ClickEvent.getType());
addMouseWheelHandler(new MouseWheelHandler() {
public void onMouseWheel(MouseWheelEvent event) {
event.preventDefault();
if (event.isNorth()) {
moveImages(true);
} else {
moveImages(false);
}
}
});
}
示例4: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(final KeyDownEvent event) {
if (event.getNativeKeyCode() == keyCode) {
actionButton.fireEvent( new GwtEvent<ClickHandler>() {
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
return ClickEvent.getType();
}
@Override
protected void dispatch(final ClickHandler handler) {
handler.onClick(null);
}
});
}
}
示例5: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的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();
}
}
}
示例6: install
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
/**
* Installs a key handler for key events on this window.
*
* @param handler handler to receive key events.
*/
static void install(KeySignalHandler handler) {
//
// NOTE: There are three potential candidate elements for sinking keyboard
// events: the window, the document, and the document body. IE7 does not
// fire events on the window element, and GWT's RootPanel is already a
// listener on the body, leaving the document as the only cross-browser
// whole-window event-sinking 'element'.
//
DocumentPanel panel = new DocumentPanel(handler);
panel.setElement(Document.get().<Element>cast());
panel.addDomHandler(panel, KeyDownEvent.getType());
panel.addDomHandler(panel, KeyPressEvent.getType());
panel.addDomHandler(panel, KeyUpEvent.getType());
RootPanel.detachOnWindowClose(panel);
panel.onAttach();
}
示例7: isRightButtonModKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
protected boolean isRightButtonModKeyDown(KeyDownEvent event) {
//Here we only initiate login on enter if the login and password are set
//We actually do it here instead of checking for the right button modifier
//because this is our indicator for doing login on enter. This allows to
//avoid error caused by the Enter pressed by the user during the login and
//password field's auto completion.
boolean result = true;
try{
//Validate the form data
validate( getUsername(), getPassword() );
} catch ( UserLoginException e ){
result = false;
}
return result;
}
示例8: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent event) {
int keyCode = event.getNativeKeyCode();
if((keyCode == KEY_BACKSPACE || keyCode >= KEY_DELETE)
&& keyCode != 91 && keyCode != 93) { // Command/Window keyboard keys
cancelTimer();
timer = new Timer() {
public void run() {
dataProvider.setFilter(filterTextBox.getValue());
}
};
timer.schedule(TIMEOUT);
} else if(keyCode == KEY_ENTER) {
cancelTimer();
dataProvider.setFilter(filterTextBox.getValue());
}
}
示例9: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent event) {
int keyCode = event.getNativeKeyCode();
if((keyCode == KEY_BACKSPACE || keyCode >= KEY_DELETE)
&& keyCode != 91 && keyCode != 93) { // Command/Window keyboard keys
cancelTimer();
timer = new Timer() {
public void run() {
eventBus.fireEventFromSource(new SearchEvent(searchInput.getValue()), searchInput);
}
};
timer.schedule(TIMEOUT);
} else if(keyCode == KEY_ENTER) {
cancelTimer();
eventBus.fireEventFromSource(new SearchEvent(searchInput.getValue()), searchInput);
}
}
示例10: Hashtags
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
public Hashtags() {
initWidget(uiBinder.createAndBindUi(this));
hashtagTextBox.setVisibleLength(VISIBLE_LENGTH);
hashtagTextBox.addKeyDownHandler(
new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent e) {
if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
onCancel(null);
} else if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
onAdd(null);
}
}
});
addHashtagIcon.addDomHandler(
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
onOpenForm();
}
},
ClickEvent.getType());
}
示例11: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent event) {
int key = event.getNativeKeyCode();
if (event.isControlKeyDown()) {
if (key == KEY_PLUS || key == KEY_MINUS) {
app.getToolbar().zoomChangeClicked(key == KEY_PLUS ? 1 : -1);
event.preventDefault();
}
} else if (!event.isShiftKeyDown()) {
boolean handled = true;
switch (key) {
case KeyCodes.KEY_HOME:
changePage(0, -1, -1);
break;
case KeyCodes.KEY_END:
changePage(dataStore.getPageCount() - 1, 1, 1);
break;
default:
handled = false;
}
if (handled)
event.preventDefault();
}
}
示例12: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent p_event)
{
switch( p_event.getNativeKeyCode() )
{
case KeyCodes.KEY_ESCAPE:
hide();
p_event.stopPropagation();
break;
case KeyCodes.KEY_ENTER:
sendMessage();
p_event.stopPropagation();
p_event.getNativeEvent().stopPropagation();
break;
default:
break;
}
}
示例13: addKeyDownHandler
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
private void addKeyDownHandler(final PropertyEditorFieldInfo property,
final PropertyEditorPasswordTextBox passwordTextBox) {
passwordTextBox.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
if (validate(property,
passwordTextBox.getText())) {
passwordTextBox.clearOldValidationErrors();
property.setCurrentStringValue(passwordTextBox.getText());
propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property,
passwordTextBox.getText()));
} else {
passwordTextBox.setValidationError(getValidatorErrorMessage(property,
passwordTextBox.getText()));
passwordTextBox.setText(property.getCurrentStringValue());
}
}
}
});
}
示例14: addEnterKeyHandler
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
private void addEnterKeyHandler(final PropertyEditorFieldInfo property,
final PropertyEditorTextBox textBox) {
textBox.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
if (validate(property,
textBox.getText())) {
textBox.clearOldValidationErrors();
property.setCurrentStringValue(textBox.getText());
propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property,
textBox.getText()));
} else {
textBox.setValidationError(getValidatorErrorMessage(property,
textBox.getText()));
textBox.setText(property.getCurrentStringValue());
}
}
}
});
}
示例15: onKeyDown
import com.google.gwt.event.dom.client.KeyDownEvent; //导入依赖的package包/类
@Override
public void onKeyDown(final KeyDownEvent event) {
final GridWidget selectedGridWidget = getSelectedGridWidget();
if (selectedGridWidget == null) {
return;
}
final KeyboardOperation operation = getOperation(event);
if (operation == null) {
return;
}
final boolean redraw = operation.perform(selectedGridWidget,
event.isShiftKeyDown(),
event.isControlKeyDown());
event.preventDefault();
event.stopPropagation();
flushDOMElements(selectedGridWidget);
if (redraw) {
gridLayer.draw();
}
}