本文整理匯總了Java中com.google.gwt.dom.client.NativeEvent類的典型用法代碼示例。如果您正苦於以下問題:Java NativeEvent類的具體用法?Java NativeEvent怎麽用?Java NativeEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NativeEvent類屬於com.google.gwt.dom.client包,在下文中一共展示了NativeEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTouchEvent
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Override
public void onTouchEvent(TouchEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
JsArray<Touch> touches = nativeEvent.getTouches();
boolean isMouseClick = isMouseClick(touches); // method is also called
// when MouseEvents
// occur
boolean isOneFingerTouch = isOneFingerTouch(touches);
switch (event.getType()) {
case TOUCH_START:
if (isMouseClick || isOneFingerTouch) {
onTouchStart(nativeEvent);
} else {
onTouchCancel(nativeEvent);
}
break;
case TOUCH_CANCEL:
case TOUCH_END:
onTouchEnd(nativeEvent);
break;
case TOUCH_MOVE:
if (isMouseClick || isOneFingerTouch) {
onTouchMove(nativeEvent);
} else {
onTouchCancel(nativeEvent);
}
break;
default:
break;
}
}
示例2: onMouseDown
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Override
public void onMouseDown(MouseDownEvent event) {
super.onMouseDown(event);
if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
event.stopPropagation();
event.preventDefault();
}
DiagramController con =this.getController();
con.setPropTable(ptable);
}
示例3: createToolboxTouchStartHandler
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
private EventHandlerProxy createToolboxTouchStartHandler() {
Command command = new Command() {
@Override
public void execute(NativeEvent event) {
event.preventDefault();
}
};
return handlerFactory.createUserTouchStartHandler(command);
}
示例4: createZoomOutButtonUserDownHandler
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
private EventHandlerProxy createZoomOutButtonUserDownHandler() {
Command command = new Command() {
@Override
public void execute(NativeEvent event) {
zoomOut();
zoomOutTicker.scheduleRepeating(200);
event.preventDefault();
}
};
return handlerFactory.createUserDownHandler(command);
}
示例5: setPosition
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Override
protected void setPosition(NativeEvent event) {
if (isAttached()) {
event.preventDefault();
int positionX = getPositionX(event);
moveScroll(positionX > 0 ? positionX : 0, true);
if (!isPressed()) {// robimy seeka tylko gdy zakonczono dotyk
seekInMedia(positionX > 0 ? positionX : 0);
}
}
}
示例6: onTouchMove
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
public void onTouchMove(NativeEvent event) {
if (getView() != null) {
if (NOT_MOBILE_BROWSER) {
event.preventDefault();
}
callOnMoveHandlers(new ConnectionMoveEvent(getPositionX(event), getPositionY(event), event));
}
}
示例7: updateOnTouchStart
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
public void updateOnTouchStart(NativeEvent onTouchStartEvent) {
int y = touchEventReader.getScreenY(onTouchStartEvent);
int x = touchEventReader.getX(onTouchStartEvent);
boolean multiTouch = touchEventReader.isMoreThenOneFingerTouch(onTouchStartEvent);
touchModel.setStartScrollTopPossition(windowDelegate.getScrollTop());
touchModel.setStartY(y);
touchModel.setStartX(x);
touchModel.setLastEndX(x);
touchModel.setEndX(-1);
touchModel.setMultiTouch(multiTouch);
touchModel.setSwipeStarted(false);
touchModel.setTouchReservation(false);
touchModel.setVerticalSwipeDetected(false);
}
示例8: testClickLink
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testClickLink() {
AnchorElement anchorElement = Document.get().createAnchorElement();
anchorElement.setHref("#href1");
Document.get().getBody().appendChild(anchorElement);
try {
History.newItem("something_as_base");
addHistoryListenerImpl(
event -> {
assertEquals("href1", event.getValue());
finishTest();
});
delayTestFinish(5000);
NativeEvent clickEvent =
Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
anchorElement.dispatchEvent(clickEvent);
} finally {
Document.get().getBody().removeChild(anchorElement);
}
}
示例9: onTouchMove
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
private void onTouchMove(NativeEvent event) {
touchEndTimer.cancel();
if (!touchController.canMove(multiPageController)) {
return;
}
// nie zawsze wystepuje event touchend na androidzie - emulacja
// zachownaia
touchController.updateEndPoint(event);
if (touchController.isReadyToStartAnimation()) {
startAnimation(event);
} else {
touchController.setVerticalSwipeDetected(true);
}
}
示例10: onTouchEnd
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
private void onTouchEnd(NativeEvent event) {
touchEndTimer.cancel();
if (touchController.isSwipeStarted()) {
touchEventReader.preventDefault(event);
touchController.updateOnTouchEnd(event);
if (touchController.canSwitchPage()) {
multiPageController.switchPage();
} else {
multiPageController.animatePageSwitch();
}
touchController.setSwypeStarted(false);
}
touchController.resetTouchModel();
multiPageController.resetFocusAndStyles();
}
示例11: onTouchEventTest_TOUCH_END_isNotSwipeStartedTest
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Test
public void onTouchEventTest_TOUCH_END_isNotSwipeStartedTest() {
// when
when(touchEvent.getType()).thenReturn(TouchTypes.TOUCH_END);
NativeEvent nativeEvent = mock(NativeEvent.class);
when(touchEvent.getNativeEvent()).thenReturn(nativeEvent);
// given
testObj.onTouchEvent(touchEvent);
// then
InOrder inOrder = inOrder(userAgentUtil, touchEventReader, touchController, touchEndTimerFactory, touchEndTimer, touchEvent, multiPageController);
inOrder.verify(touchEvent).getType();
inOrder.verify(touchEvent).getNativeEvent();
inOrder.verify(touchEndTimer).cancel();
inOrder.verify(touchController).isSwipeStarted();
inOrder.verify(touchController).resetTouchModel();
inOrder.verify(multiPageController).resetFocusAndStyles();
}
示例12: onTouchEventTest_TOUCH_MOVE_isNotHorizontalSwipeTest
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Test
public void onTouchEventTest_TOUCH_MOVE_isNotHorizontalSwipeTest() {
// when
when(touchEvent.getType()).thenReturn(TouchTypes.TOUCH_MOVE);
when(touchController.canMove(multiPageController)).thenReturn(true);
when(touchController.isReadyToStartAnimation()).thenReturn(false);
NativeEvent nativeEvent = mock(NativeEvent.class);
when(touchEvent.getNativeEvent()).thenReturn(nativeEvent);
// given
testObj.onTouchEvent(touchEvent);
// then
InOrder inOrder = inOrder(userAgentUtil, touchEventReader, touchController, touchEndTimerFactory, touchEndTimer, touchEvent, multiPageController);
inOrder.verify(touchEvent).getType();
inOrder.verify(touchEvent).getNativeEvent();
inOrder.verify(touchEndTimer).cancel();
inOrder.verify(touchController).canMove(multiPageController);
inOrder.verify(touchController).updateEndPoint(nativeEvent);
inOrder.verify(touchController).isReadyToStartAnimation();
inOrder.verify(touchController).setVerticalSwipeDetected(true);
}
示例13: onMouseUp
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Override
public void onMouseUp(MouseUpEvent event) {
if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
event.stopPropagation();
event.preventDefault();
controller.showMenu(this);
this.setFocus();
}
}
示例14: Leaf
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
/**
* Create a leaf node for the Tree
*
* @param name name of the TreeItem
* @param module Attached moduleId for the TreeItem
*/
public Leaf(String name,
T module,
String style) {
// add context menu
this.menu = new ContextMenu();
label = new Label(name);
this.setWidget(label);
label.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
// display the context menu when right click
if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
menu.setPopupPosition(event.getClientX(), event.getClientY());
menu.show();
}
}
});
// set moduleId
this.module = module;
this.addStyleName("bda-treeleaf");
if (!style.equals(""))
this.addStyleName(style);
}
示例15: onTouchEventTest_TOUCH_START_complete_test
import com.google.gwt.dom.client.NativeEvent; //導入依賴的package包/類
@Test
public void onTouchEventTest_TOUCH_START_complete_test() {
// when
when(touchEvent.getType()).thenReturn(TouchTypes.TOUCH_START);
when(touchController.canSwype(multiPageController)).thenReturn(true);
when(touchController.isSwypeStarted()).thenReturn(false);
NativeEvent nativeEvent = mock(NativeEvent.class);
when(touchEvent.getNativeEvent()).thenReturn(nativeEvent);
// given
testObj.onTouchEvent(touchEvent);
// then
InOrder inOrder = inOrder(userAgentUtil, touchEventReader, touchController, touchEndTimerFactory, touchEndTimer, touchEvent, multiPageController);
inOrder.verify(touchEvent).getType();
inOrder.verify(touchEvent).getNativeEvent();
inOrder.verify(touchController).canSwype(multiPageController);
inOrder.verify(touchController).isSwypeStarted();
inOrder.verify(touchController).updateOnTouchStart(nativeEvent);
inOrder.verify(touchEndTimer).cancel();
inOrder.verify(multiPageController).resetFocusAndStyles();
}