本文整理汇总了Java中com.google.gwt.user.client.Event.preventDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Event.preventDefault方法的具体用法?Java Event.preventDefault怎么用?Java Event.preventDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.Event
的用法示例。
在下文中一共展示了Event.preventDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
event.preventDefault();
int eventType = event.getTypeInt();
switch (eventType) {
case ONMOUSEDOWN:
case ONTOUCHSTART:
onClick();
break;
case ONMOUSEUP:
if (!singleClick) {
onClick();
}
break;
case ONMOUSEOVER:
onMouseOver();
break;
case ONTOUCHEND:
case ONMOUSEOUT:
onMouseOut();
break;
}
}
示例2: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN:
SelectionMode mode = null;
for (SelectionMode m: SelectionMode.values())
if (hasUnselectedDays(m)) {
mode = m; break;
}
if (mode != null)
setAllSelected(true, mode);
else
setAllSelected(false, SelectionMode.All);
if (iCursor != null) iPanel.getWidget().setCursor(iCursor);
event.preventDefault();
break;
}
super.onBrowserEvent(event);
}
示例3: handleMouseDownEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
/**
* Handles special behavior of the mouse down event.
*
* @param event
*/
private void handleMouseDownEvent(Event event) {
/*
* Prevent the keyboard focus from leaving the textfield by preventing
* the default behaviour of the browser. Fixes #4285.
*/
if (event.getTypeInt() == Event.ONMOUSEDOWN) {
debug("VComboBoxMultiselect: blocking mouseDown event to avoid blur");
event.preventDefault();
event.stopPropagation();
/*
* In IE the above wont work, the blur event will still trigger. So,
* we set a flag here to prevent the next blur event from happening.
* This is not needed if do not already have focus, in that case
* there will not be any blur event and we should not cancel the
* next blur.
*/
if (BrowserInfo.get()
.isIE() && this.focused) {
this.preventNextBlurEventInIE = true;
debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
}
}
}
示例4: handleLinkClick
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@UsedByApp
public void handleLinkClick(Event event) {
Element target = Element.as(event.getEventTarget());
String href = target.getAttribute("href");
if (href.startsWith("send:")) {
String msg = href.substring("send:".length());
msg = URL.decode(msg);
if (lastVisiblePeer != null) {
messenger.sendMessage(lastVisiblePeer, msg);
event.preventDefault();
}
} else {
if (JsElectronApp.isElectron()) {
JsElectronApp.openUrlExternal(href);
event.preventDefault();
}
}
}
示例5: showContextMenu
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void showContextMenu(Event event) {
if (!readonly && !disabled) {
if (!isSelected()) {
getConnector().setContextMenuSelection(true);
toggleSelection();
}
if (customContextMenu == null) {
super.showContextMenu(event);
} else {
int left = event.getClientX();
int top = event.getClientY();
top += Window.getScrollTop();
left += Window.getScrollLeft();
showContextMenuPopup(left, top);
event.stopPropagation();
event.preventDefault();
}
}
}
示例6: captureEvents
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
protected void captureEvents(Event event) {
event.preventDefault();
if (isEnabled() && event.getButton() == Event.BUTTON_LEFT) {
if (!dragDrop) {
dragDrop = true;
DOM.setCapture(resizeElement);
ComputedStyle cs = new ComputedStyle(getElement());
setWidth(cs.getProperty("width"));
setHeight(cs.getProperty("height"));
getTextArea().getStyle().setProperty("width", "100%");
getTextArea().getStyle().setProperty("height", "100%");
}
}
}
示例7: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
if (contextMenuHandler != null && event.getTypeInt() == Event.ONCONTEXTMENU) {
contextMenuHandler.onContextMenu(event);
return;
}
if ((event.getTypeInt() == Event.ONCLICK
|| event.getTypeInt() == Event.ONMOUSEDOWN)
&& event.getButton() != NativeEvent.BUTTON_LEFT) {
event.preventDefault();
event.stopPropagation();
return;
}
super.onBrowserEvent(event);
}
示例8: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN:
MouseDownEvent.fireNativeEvent(event, this);
event.stopPropagation();
event.preventDefault();
break;
}
}
示例9: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONKEYPRESS:
MenuItem item = iAccessKeys.get(Character.toLowerCase((char)event.getCharCode()));
if (item != null) {
event.stopPropagation();
event.preventDefault();
item.getScheduledCommand().execute();
}
}
super.onBrowserEvent(event);
}
示例10: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
Element target = DOM.eventGetTarget(event);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN:
boolean open = iFilterOpen.getElement().equals(target);
boolean close = iFilterClose.getElement().equals(target);
boolean clear = iFilterClear.getElement().equals(target);
boolean filter = iFilter.getElement().equals(target);
if (isFilterPopupShowing() || close) {
hideFilterPopup();
} else if (open) {
hideSuggestions();
showFilterPopup();
}
if (clear) {
iFilter.setText("");
removeAllChips();
setAriaLabel(toAriaString());
ValueChangeEvent.fire(FilterBox.this, getValue());
}
if (!filter) {
event.stopPropagation();
event.preventDefault();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
iFilter.setFocus(true);
}
});
}
break;
}
}
示例11: moveWindow
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
private void moveWindow(Event event) {
if (dragging) {
if (cursorInsideBrowserContentArea(event)) {
// Only drag while cursor is inside the browser client area
final int x = WidgetUtil.getTouchOrMouseClientX(event) - startX
+ origX;
final int y = WidgetUtil.getTouchOrMouseClientY(event) - startY
+ origY;
setPopupPosition(x, y);
}
event.preventDefault();
}
}
示例12: beginMovingWindow
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
private void beginMovingWindow(Event event) {
if (draggable) {
showDraggingCurtain();
dragging = true;
startX = WidgetUtil.getTouchOrMouseClientX(event);
startY = WidgetUtil.getTouchOrMouseClientY(event);
origX = getElement().getAbsoluteLeft();
origY = getElement().getAbsoluteTop();
DOM.setCapture(getElement());
event.preventDefault();
}
}
示例13: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (isEnabled() && event.getTypeInt() == Event.ONCONTEXTMENU) {
if (getStyleName().contains("-header-sortable")) {
_delegate.showSortMenu(td, cid);
}
event.preventDefault();
event.stopPropagation();
}
}
示例14: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
/**
* Overrides the same method as per Label. Updates the CSS style on the parent
* DIV, and then passes on control to the superclass implementation.
*
* @see com.google.gwt.user.client.ui.Label#onBrowserEvent(com.google.gwt.user.client.Event)
*/
@Override
public void onBrowserEvent(Event event) {
switch (event.getTypeInt()) {
case Event.ONMOUSEDOWN:
me.replaceClassName(ButtonStyle.mouseUp, ButtonStyle.mouseDown);
if (cancelMouseDownBubble) {
event.stopPropagation();
}
if (preventMouseDownDefault) {
event.preventDefault();
}
break;
case Event.ONMOUSEUP:
me.replaceClassName(ButtonStyle.mouseDown, ButtonStyle.mouseUp);
break;
case Event.ONMOUSEOVER:
me.replaceClassName(ButtonStyle.mouseOut, ButtonStyle.mouseOver);
break;
case Event.ONMOUSEOUT:
me.replaceClassName(ButtonStyle.mouseOver, ButtonStyle.mouseOut);
break;
}
// Call to super to handle all event generation.
super.onBrowserEvent(event);
}
示例15: onBrowserEvent
import com.google.gwt.user.client.Event; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
if (Event.ONMOUSEMOVE == DOM.eventGetType(event) && !iSelection.isActive() && iMoving != null) {
iMoving.onBrowserEvent(event);
if (iMoving.iCursor != null)
getElement().getStyle().setCursor(iMoving.iCursor);
return;
}
double x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft();
double y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop();
int slot = 3 * Math.min(Math.max(0, (int)Math.round(4 * (y - 1 + iStart * iCellHeight) / iCellHeight)), 96);
int day = Math.min(Math.max(0, (int)Math.floor((x - 2) / iCellWidth)), iDays.length - 1);
int dayOfWeek = iDays[day];
int weeks = (isSingleRoom() ? iSelectedWeeks.size() : iRoomResources.size());
int week = Math.min(Math.max(0, (int)Math.floor(weeks * (x - 2 - iCellWidth * day) / (iCellWidth - 6))), weeks - 1);
int h = slot / 12;
int m = 5 * (slot % 12);
String time = (CONSTANTS.useAmPm() ? (h == 0 ? "12": h <= 12 ? h : h-12) : h) + ":" + (m < 10 ? "0" : "") + m + (CONSTANTS.useAmPm() ? (h <= 11 ? "a" : "p") : "");
String text = (iDayOfWeeks == null ? CONSTANTS.longDays()[dayOfWeek] : iDayOfWeeks.get(dayOfWeek)) + " " + (isSingleRoom() ? iSelectedWeeks.get(week) : iSelectedWeeks.get(0)).getDayNames().get(dayOfWeek) +
" " + time + (isSingleRoom() ? "" : " " + iRoomResources.get(week).getName());
ResourceInterface room = (isSingleRoom() ? iRoomResources.get(0) : iRoomResources.get(week));
iPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop());
getElement().getStyle().setCursor(Cursor.CROSSHAIR);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN:
iSelection.setStart(dayOfWeek, slot, week);
iSelection.setEnd(dayOfWeek, slot, week);
iSelection.setVisible(true);
iSelection.setActive(true);
break;
case Event.ONMOUSEMOVE:
iSelection.setEnd(dayOfWeek, slot, week);
if (!iPopup.isShowing()) iPopup.show();
if (!room.getId().equals(iLastRoomId)) {
RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
iLastRoomId = room.getId();
}
break;
case Event.ONMOUSEUP:
onMouseUp();
break;
case Event.ONMOUSEOVER:
if (!iPopup.isShowing() && (iSelection.isActive() || iMoving == null)) iPopup.show();
if (iSelection.isActive() && !iSelection.isVisible()) {
iSelection.setVisible(true);
}
if (!room.getId().equals(iLastRoomId)) {
RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
iLastRoomId = room.getId();
}
break;
case Event.ONMOUSEOUT:
Element child = DOM.eventGetToElement(event);
if (child != null && !getElement().isOrHasChild(child)) {
if (iPopup.isShowing()) {
iPopup.hide();
RoomHint.hideHint(); iLastRoomId = null;
}
iSelection.setVisible(false);
}
/*
if (iSelection.isActive() && !DOM.isOrHasChild(TimeGrid.this.getElement(), DOM.eventGetToElement(event))) {
iSelection.setActive(false);
}
*/
break;
}
iHint.setText((iSelection.isVisible() && iSelection.isActive() ? iSelection.toString() : text));
event.preventDefault();
event.stopPropagation();
}