本文整理汇总了Java中com.google.gwt.user.client.Event.NativePreviewEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java NativePreviewEvent.consume方法的具体用法?Java NativePreviewEvent.consume怎么用?Java NativePreviewEvent.consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.Event.NativePreviewEvent
的用法示例。
在下文中一共展示了NativePreviewEvent.consume方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreviewNativeEvent
import com.google.gwt.user.client.Event.NativePreviewEvent; //导入方法依赖的package包/类
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
if (event.getNativeEvent().getType().equals("keydown") && event.isFirstHandler()) {
switch (event.getNativeEvent().getKeyCode()) {
case KeyCodes.KEY_ESCAPE:
if (!(getFocusedWidget() instanceof PreventsKeyboardClose)) {
event.consume();
closeCancel();
}
break;
case KeyCodes.KEY_ENTER:
// typeahead box hides this panel automatically if possible
if (!(getFocusedWidget() instanceof PreventsKeyboardClose)) {
event.consume();
closeOk();
}
break;
}
}
}
示例2: onPreviewNativeEvent
import com.google.gwt.user.client.Event.NativePreviewEvent; //导入方法依赖的package包/类
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
event.consume();
event.cancel();
}
示例3: onPreviewNativeEvent
import com.google.gwt.user.client.Event.NativePreviewEvent; //导入方法依赖的package包/类
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
event.consume();
event.cancel();
}
示例4: previewNativeEvent
import com.google.gwt.user.client.Event.NativePreviewEvent; //导入方法依赖的package包/类
/**
* Preview the {@link NativePreviewEvent}.
*
* @param event
* the {@link NativePreviewEvent}
*/
private void previewNativeEvent(NativePreviewEvent event) {
// If the event has been canceled or consumed, ignore it
if (!event.isCanceled()) {
// If the event targets the auto close or the partner, consume it.
Event nativeEvent = Event.as(event.getNativeEvent());
boolean eventTargetsPopupOrPartner = eventTargetsPopup(nativeEvent) || eventTargetsPartner(nativeEvent);
if (eventTargetsPopupOrPartner) {
event.consume();
}
// Switch on the event type
int type = nativeEvent.getTypeInt();
switch (type) {
case Event.ONMOUSEDOWN:
case Event.ONTOUCHSTART:
// Don't eat events if event capture is enabled, as this can
// interfere with dialog dragging, for example.
if (DOM.getCaptureElement() != null) {
event.consume();
return;
}
if (!eventTargetsPopupOrPartner) {
close();
return;
}
break;
case Event.ONMOUSEUP:
case Event.ONMOUSEMOVE:
case Event.ONCLICK:
case Event.ONDBLCLICK:
case Event.ONTOUCHEND: {
// Don't eat events if event capture is enabled, as this can
// interfere with dialog dragging, for example.
if (DOM.getCaptureElement() != null) {
event.consume();
return;
}
break;
}
case Event.ONFOCUS: {
EventTarget evTarget = nativeEvent.getEventTarget();
if (Element.is(evTarget)) {
Element target = Element.as(evTarget);
if (!eventTargetsPopupOrPartner && (target != null)) {
blur(target);
event.cancel();
return;
}
}
break;
}
}
}
}