本文整理汇总了Java中com.google.gwt.dom.client.Element.as方法的典型用法代码示例。如果您正苦于以下问题:Java Element.as方法的具体用法?Java Element.as怎么用?Java Element.as使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.Element
的用法示例。
在下文中一共展示了Element.as方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMouseDown
import com.google.gwt.dom.client.Element; //导入方法依赖的package包/类
@Override
public void onMouseDown(MouseDownEvent event) {
startX = event.getClientX();
startY = event.getClientY();
if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
return;
}
clickTarget = Element.as(event.getNativeEvent().getEventTarget());
mouseMoveCanceled = false;
if ((weekGrid.getCalendar().isItemMoveAllowed() && getCalendarItem().isMoveable())
|| (clickTargetsResize() && getCalendarItem().isResizeable())) {
moveRegistration = addMouseMoveHandler(this);
setFocus(true);
try {
startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight);
startXrelative = (event.getRelativeX(weekGrid.getElement())
- weekGrid.timebar.getOffsetWidth())
% getDateCellWidth();
} catch (Exception e) {
GWT.log("Exception calculating relative start position", e);
}
mouseMoveStarted = false;
Style s = getElement().getStyle();
s.setZIndex(1000);
startDatetimeFrom = (Date) calendarItem.getStartTime().clone();
startDatetimeTo = (Date) calendarItem.getEndTime().clone();
Event.setCapture(getElement());
}
// make sure the right cursor is always displayed
if (clickTargetsResize() && getCalendarItem().isResizeable()) {
addGlobalResizeStyle();
}
/*
* We need to stop the event propagation or else the WeekGrid range
* select will kick in
*/
event.stopPropagation();
event.preventDefault();
}
示例2: onMouseUp
import com.google.gwt.dom.client.Element; //导入方法依赖的package包/类
@Override
public void onMouseUp(MouseUpEvent event) {
if (mouseMoveCanceled
|| event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
return;
}
Event.releaseCapture(getElement());
setFocus(false);
if (moveRegistration != null) {
moveRegistration.removeHandler();
moveRegistration = null;
}
int endX = event.getClientX();
int endY = event.getClientY();
int xDiff = 0, yDiff = 0;
if (startX != -1 && startY != -1) {
// Drag started
xDiff = startX - endX;
yDiff = startY - endY;
}
startX = -1;
startY = -1;
mouseMoveStarted = false;
Style s = getElement().getStyle();
s.setZIndex(1);
if (!clickTargetsResize()) {
// check if mouse has moved over threshold of 3 pixels
boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3);
if (!weekGrid.getCalendar().isDisabled() && mouseMoved) {
// Item Move:
// - calendar must be enabled
// - calendar must not be in read-only mode
weekGrid.itemMoved(this);
} else if (!weekGrid.getCalendar().isDisabled() && getCalendarItem().isClickable()) {
// Item Click:
// - calendar must be enabled (read-only is allowed)
EventTarget et = event.getNativeEvent().getEventTarget();
Element e = Element.as(et);
if (e == caption || e == eventContent
|| e.getParentElement() == caption) {
if (weekGrid.getCalendar().getItemClickListener() != null) {
weekGrid.getCalendar().getItemClickListener().itemClick(calendarItem);
}
}
}
} else {
// click targeted resize bar
removeGlobalResizeStyle();
if (weekGrid.getCalendar().getItemResizeListener() != null) {
weekGrid.getCalendar().getItemResizeListener().itemResized(calendarItem);
}
dateCell.recalculateItemWidths();
}
}