本文整理汇总了Java中elemental.events.Event.preventDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Event.preventDefault方法的具体用法?Java Event.preventDefault怎么用?Java Event.preventDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elemental.events.Event
的用法示例。
在下文中一共展示了Event.preventDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runActions
import elemental.events.Event; //导入方法依赖的package包/类
/**
* Finds and runs an action cancelling original key event
*
* @param actionIds list containing action ids
* @param keyEvent original key event
*/
private void runActions(List<String> actionIds, Event keyEvent) {
for (String actionId : actionIds) {
Action action = actionManager.getAction(actionId);
if (action == null) {
continue;
}
ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager);
action.update(e);
if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
/** Stop handling the key event */
keyEvent.preventDefault();
keyEvent.stopPropagation();
/** Perform the action */
action.actionPerformed(e);
}
}
}
示例2: handleEvent
import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(final Event evt) {
if (evt instanceof KeyboardEvent) {
final KeyboardEvent keyEvent = (KeyboardEvent) evt;
switch (keyEvent.getKeyCode()) {
case KeyCodes.KEY_ESCAPE:
Scheduler.get()
.scheduleDeferred(
new ScheduledCommand() {
@Override
public void execute() {
popupWidget.hide();
}
});
break;
case KeyCodes.KEY_DOWN:
focusNext();
break;
case KeyCodes.KEY_UP:
focusPrevious();
break;
case KeyCodes.KEY_HOME:
focusFirst();
break;
case KeyCodes.KEY_END:
focusLast();
break;
case KeyCodes.KEY_ENTER:
evt.preventDefault();
evt.stopImmediatePropagation();
validateItem();
break;
default:
}
}
}
示例3: handleEvent
import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
if (Event.KEYDOWN.equalsIgnoreCase(evt.getType())) {
final KeyboardEvent keyEvent = (KeyboardEvent) evt;
switch (keyEvent.getKeyCode()) {
case KeyCodes.KEY_ESCAPE:
Scheduler.get().scheduleDeferred(this::hide);
break;
case KeyCodes.KEY_DOWN:
selectNext();
evt.preventDefault();
break;
case KeyCodes.KEY_UP:
selectPrevious();
evt.preventDefault();
break;
case KeyCodes.KEY_PAGEUP:
selectPreviousPage();
evt.preventDefault();
break;
case KeyCodes.KEY_PAGEDOWN:
selectNextPage();
evt.preventDefault();
break;
case KeyCodes.KEY_HOME:
selectFirst();
break;
case KeyCodes.KEY_END:
selectLast();
break;
case KeyCodes.KEY_ENTER:
evt.preventDefault();
evt.stopImmediatePropagation();
validateItem(true);
break;
case KeyCodes.KEY_TAB:
evt.preventDefault();
evt.stopImmediatePropagation();
validateItem(false);
break;
}
} else if (Event.SCROLL.equalsIgnoreCase(evt.getType())) {
updateIfNecessary();
} else if (Event.FOCUS.equalsIgnoreCase(evt.getType())) {
focused = true;
}
}
示例4: handleEvent
import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
// Don't even bother to do anything unless we have someone ready to
// handle events.
if (getDelegate() == null
|| (primaryMouseButtonOnly
&& ((MouseEvent) evt).getButton() != MouseEvent.Button.PRIMARY)) {
return;
}
Element eventTarget = (Element) evt.getTarget();
if (CssUtils.containsClassName(eventTarget, css.expandControl())) {
onExpansionControlEvent(evt, eventTarget);
} else {
Element treeNodeBody =
CssUtils.getAncestorOrSelfWithClassName(eventTarget, css.treeNodeBody());
if (treeNodeBody != null) {
// this code emulate double click for tablets
if (Event.MOUSEDOWN.equals(evt.getType())) {
double currentClickMs = Duration.currentTimeMillis();
if (currentClickMs - previousClickMs < MouseGestureListener.MAX_CLICK_TIMEOUT_MS
&& treeNodeBody.equals(previousClickTreeNodeBody)) {
if (BrowserUtils.isAndroid() || BrowserUtils.isIPad() || BrowserUtils.isIphone()) {
evt.stopPropagation();
evt.preventDefault();
doActionsForDoubleClick(treeNodeBody, evt);
}
return;
} else {
this.previousClickMs = currentClickMs;
this.previousClickTreeNodeBody = treeNodeBody;
}
}
onTreeNodeBodyChildEvent(evt, treeNodeBody);
} else {
onOtherEvent(evt);
}
}
}
示例5: handleEvent
import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
evt.stopPropagation();
evt.preventDefault();
}
示例6: PopupWidget
import elemental.events.Event; //导入方法依赖的package包/类
public PopupWidget(final PopupResources popupResources, String title) {
this.popupResources = popupResources;
popupElement = Elements.createDivElement(popupResources.popupStyle().popup());
Element headerElement = Elements.createDivElement(popupResources.popupStyle().header());
headerElement.setInnerText(title);
popupElement.appendChild(headerElement);
popupBodyElement = Elements.createDivElement(popupResources.popupStyle().body());
popupElement.appendChild(popupBodyElement);
listElement = Elements.createUListElement();
popupBodyElement.appendChild(listElement);
popupListener =
new EventListener() {
@Override
public void handleEvent(final Event evt) {
if (evt instanceof MouseEvent) {
final MouseEvent mouseEvent = (MouseEvent) evt;
final EventTarget target = mouseEvent.getTarget();
if (target instanceof Element) {
final Element elementTarget = (Element) target;
if (!PopupWidget.this.popupElement.contains(elementTarget)) {
hide();
evt.preventDefault();
}
}
}
// else won't happen
}
};
keyboardListener = new PopupKeyDownListener(this, this.listElement);
}