use of com.google.gwt.dom.client.NativeEvent in project che by eclipse.
the class KeyboardNavigationHandler method 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;
}
}
use of com.google.gwt.dom.client.NativeEvent in project libgdx by libgdx.
the class AssetDownloader method loadImage.
public void loadImage(final String url, final String mimeType, final String crossOrigin, final AssetLoaderListener<ImageElement> listener) {
if (useBrowserCache || useInlineBase64) {
loadBinary(url, new AssetLoaderListener<Blob>() {
@Override
public void onProgress(double amount) {
listener.onProgress(amount);
}
@Override
public void onFailure() {
listener.onFailure();
}
@Override
public void onSuccess(Blob result) {
final ImageElement image = createImage();
if (crossOrigin != null) {
image.setAttribute("crossOrigin", crossOrigin);
}
hookImgListener(image, new ImgEventListener() {
@Override
public void onEvent(NativeEvent event) {
if (event.getType().equals("error"))
listener.onFailure();
else
listener.onSuccess(image);
}
});
if (isUseInlineBase64()) {
image.setSrc("data:" + mimeType + ";base64," + result.toBase64());
} else {
image.setSrc(url);
}
}
});
} else {
final ImageElement image = createImage();
if (crossOrigin != null) {
image.setAttribute("crossOrigin", crossOrigin);
}
hookImgListener(image, new ImgEventListener() {
@Override
public void onEvent(NativeEvent event) {
if (event.getType().equals("error"))
listener.onFailure();
else
listener.onSuccess(image);
}
});
image.setSrc(url);
}
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class ShortcutManager method swallowEvents.
private void swallowEvents(Object object) {
NativeEvent event = (NativeEvent) object;
// when seeing unhandled keys.
if (!keyBuffer_.isEmpty()) {
for (Map.Entry<KeyMapType, KeyMap> entry : keyMaps_.entrySet()) {
if (entry.getValue().isPrefix(keyBuffer_)) {
event.stopPropagation();
event.preventDefault();
return;
}
}
}
// Prevent backspace from performing a browser 'back'
if (DomUtils.preventBackspaceCausingBrowserBack(event))
return;
// Suppress save / quit events from reaching the browser
KeyCombination keys = new KeyCombination(event);
int keyCode = keys.getKeyCode();
int modifiers = keys.getModifier();
boolean isSaveQuitKey = keyCode == KeyCodes.KEY_S || keyCode == KeyCodes.KEY_W;
boolean isSaveQuitModifier = BrowseCap.isMacintosh() ? modifiers == KeyboardShortcut.META : modifiers == KeyboardShortcut.CTRL;
if (isSaveQuitKey && isSaveQuitModifier)
event.preventDefault();
// Prevent 'Ctrl+Shift+B' (toggle bookmarks)
boolean isToggleBookmarksModifier = BrowseCap.isMacintosh() ? modifiers == (KeyboardShortcut.SHIFT | KeyboardShortcut.META) : modifiers == (KeyboardShortcut.SHIFT | KeyboardShortcut.CTRL);
if (keyCode == KeyCodes.KEY_B && isToggleBookmarksModifier)
event.preventDefault();
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class WindowEx method fireBlurHandlers.
private static void fireBlurHandlers() {
NativeEvent nativeEvent = Document.get().createBlurEvent();
BlurEvent.fireNativeEvent(nativeEvent, new HasHandlers() {
public void fireEvent(GwtEvent<?> event) {
handlers_.fireEvent(event);
}
});
}
use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.
the class ModalDialogBase method onPreviewNativeEvent.
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
if (!ModalDialogTracker.isTopMost(this))
return;
if (event.getTypeInt() == Event.ONKEYDOWN) {
NativeEvent nativeEvent = event.getNativeEvent();
switch(nativeEvent.getKeyCode()) {
case KeyCodes.KEY_ENTER:
if (enterDisabled_)
break;
// allow Enter on textareas
Element e = DomUtils.getActiveElement();
if (e.hasTagName("TEXTAREA"))
return;
ThemedButton defaultButton = defaultOverrideButton_ == null ? okButton_ : defaultOverrideButton_;
if ((defaultButton != null) && defaultButton.isEnabled()) {
nativeEvent.preventDefault();
nativeEvent.stopPropagation();
event.cancel();
defaultButton.click();
}
break;
case KeyCodes.KEY_ESCAPE:
if (escapeDisabled_)
break;
onEscapeKeyDown(event);
break;
}
}
}
Aggregations