Java Code Examples for com.google.gwt.event.dom.client.KeyDownEvent#preventDefault()

The following examples show how to use com.google.gwt.event.dom.client.KeyDownEvent#preventDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SinglePageLayout.java    From djvu-html5 with GNU General Public License v2.0 6 votes vote down vote up
@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();
	}
}
 
Example 2
Source File: CubaRadioButtonGroupWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
    if ((!isEnabled() || isReadonly())
            && event.getNativeKeyCode() != KeyCodes.KEY_TAB) {
        event.preventDefault();
    }
}
 
Example 3
Source File: CubaCheckBoxWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
    if ((!isEnabled() || isReadOnly())
            && event.getNativeKeyCode() != KeyCodes.KEY_TAB) {
        event.preventDefault();
    }
}
 
Example 4
Source File: CubaCheckBoxGroupWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
    if ((!isEnabled() || isReadonly())
            && event.getNativeKeyCode() != KeyCodes.KEY_TAB) {
        event.preventDefault();
    }
}
 
Example 5
Source File: CubaOptionGroupWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
    if ((!isEnabled() || isReadonly())
            && event.getNativeKeyCode() != KeyCodes.KEY_TAB) {
        event.preventDefault();
    }
}
 
Example 6
Source File: SuggestPopup.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
	int keyCode = event.getNativeKeyCode();
	if (keyCode == KeyCodes.KEY_ENTER
			&& choiceList.getSelectedIndex() != -1) {
		event.preventDefault();
		event.stopPropagation();
		select();
	} else if (keyCode == KeyCodes.KEY_ESCAPE) {
		event.preventDefault();
		close();
	}
}
 
Example 7
Source File: MaskValueBoxHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void onKeyDown(KeyDownEvent event) {
	this.keyDown = event.getNativeKeyCode();
	boolean preventDefault = false;
	switch (event.getNativeKeyCode()) {
		case KeyCodes.KEY_DELETE:
		case KeyCodes.KEY_BACKSPACE:
			if (this.token != null) {
				this.reset();
				this.maskHelper.refreshValueBox();
				event.preventDefault();
			}
			break;
		case KeyCodes.KEY_DOWN:
		case KeyCodes.KEY_UP:
			event.preventDefault();
			break;
		case KeyCodes.KEY_LEFT:
			preventDefault = this.maskHelper.focusPrevious();
			break;
		case KeyCodes.KEY_RIGHT:
			preventDefault = this.maskHelper.focusNext();

			break;
		case KeyCodes.KEY_TAB:
			if (event.isShiftKeyDown()) {
				preventDefault = this.maskHelper.focusPrevious();
			} else {
				preventDefault = this.maskHelper.focusNext();
			}
			break;
		default:
			break;
	}

	if (preventDefault) {
		event.preventDefault();
	}
	if (this.handleKeyDown(this.keyDown)) {
		this.maskHelper.refreshValueBox();
		this.schedule(this.maskHelper.initialDelayMilis);
	}
}