use of com.google.gwt.dom.client.NativeEvent in project openremote by openremote.
the class PopupPanel method previewNativeEvent.
/**
* 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() || (!previewAllNativeEvents && event.isConsumed())) {
// that popups lower on the stack do not auto hide
if (modal) {
event.cancel();
}
return;
}
// Fire the event hook and return if the event is canceled
onPreviewNativeEvent(event);
if (event.isCanceled()) {
return;
}
// If the event targets the popup or the partner, consume it
Event nativeEvent = Event.as(event.getNativeEvent());
boolean eventTargetsPopupOrPartner = eventTargetsPopup(nativeEvent) || eventTargetsPartner(nativeEvent);
if (eventTargetsPopupOrPartner) {
event.consume();
}
// event can be both canceled and consumed.
if (modal) {
event.cancel();
}
// Switch on the event type
int type = nativeEvent.getTypeInt();
switch(type) {
case Event.ONKEYDOWN:
{
if (!onKeyDownPreview((char) nativeEvent.getKeyCode(), KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
event.cancel();
}
return;
}
case Event.ONKEYUP:
{
if (!onKeyUpPreview((char) nativeEvent.getKeyCode(), KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
event.cancel();
}
return;
}
case Event.ONKEYPRESS:
{
if (!onKeyPressPreview((char) nativeEvent.getKeyCode(), KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
event.cancel();
}
return;
}
case Event.ONMOUSEDOWN:
case Event.ONTOUCHSTART:
// interfere with dialog dragging, for example.
if (DOM.getCaptureElement() != null) {
event.consume();
return;
}
if (!eventTargetsPopupOrPartner && autoHide) {
hide(true);
return;
}
break;
case Event.ONMOUSEUP:
case Event.ONMOUSEMOVE:
case Event.ONCLICK:
case Event.ONDBLCLICK:
case Event.ONTOUCHEND:
{
// interfere with dialog dragging, for example.
if (DOM.getCaptureElement() != null) {
event.consume();
return;
}
break;
}
case Event.ONFOCUS:
{
Element target = nativeEvent.getTarget();
if (modal && !eventTargetsPopupOrPartner && (target != null)) {
blur(target);
event.cancel();
return;
}
break;
}
}
}
use of com.google.gwt.dom.client.NativeEvent in project ovirt-engine by oVirt.
the class DraggableVirtualNumaPanel method onDragStart.
@UiHandler("container")
void onDragStart(DragStartEvent event) {
if (!dragEnabled) {
return;
}
// IE strikes again, for some unknown reason, in IE you can only put 'Text' as the setData first
// parameter. So if you want to pass multiple values, you have to collect them in one string, then parse
// the string on the other end instead of passing different values.
// $NON-NLS-1$
String aggregatedString = "VM_GID=" + nodeModel.getVm().getId().toString();
// $NON-NLS-1$
aggregatedString += "|PINNED=" + String.valueOf(nodeModel.isPinned());
// $NON-NLS-1$
aggregatedString += "|INDEX=" + String.valueOf(nodeModel.getIndex());
// $NON-NLS-1$
event.setData("Text", aggregatedString);
// show a ghost of the widget under cursor.
NativeEvent nativeEvent = event.getNativeEvent();
int x = nativeEvent.getClientX() - getAbsoluteLeft();
int y = nativeEvent.getClientY() - getAbsoluteTop();
event.getDataTransfer().setDragImage(getElement(), x, y);
}
use of com.google.gwt.dom.client.NativeEvent in project ovirt-engine by oVirt.
the class ColumnResizeHandler method onPreviewNativeEvent.
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
nativeEvent.preventDefault();
nativeEvent.stopPropagation();
if (BrowserEvents.MOUSEMOVE.equals(nativeEvent.getType())) {
// Calculate display-relative column width
int clientX = nativeEvent.getClientX();
int displayColumnWidth = clientX - columnAbsoluteLeft + DRAG_AREA_OFFSET;
// Adjust column width as necessary
int minimumColumnWidth = table.getMinimumColumnWidth(column);
displayColumnWidth = displayColumnWidth < minimumColumnWidth ? minimumColumnWidth : displayColumnWidth;
// Resize the column
table.resizeColumn(column, displayColumnWidth);
} else if (BrowserEvents.MOUSEUP.equals(nativeEvent.getType())) {
// Release native event handler
eventHandler.removeHandler();
// Indicate resize end
table.onResizeEnd(column, headerElement);
}
}
use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.
the class YearsMonthsSelectorViewTest method testOnYearsInputBlur.
@Test
public void testOnYearsInputBlur() {
final BlurEvent blurEvent = mock(BlurEvent.class);
final NativeEvent nativeEvent = mock(NativeEvent.class);
final EventTarget eventTarget = mock(EventTarget.class);
when(blurEvent.getNativeEvent()).thenReturn(nativeEvent);
when(nativeEvent.getRelatedEventTarget()).thenReturn(eventTarget);
view.onYearsInputBlur(blurEvent);
verify(view).handle(blurEvent);
}
use of com.google.gwt.dom.client.NativeEvent in project kie-wb-common by kiegroup.
the class DecisionNavigatorTreeViewTest method testTreeItemOnInputTextKeyPressWhenKeyIsNotEnter.
@Test
public void testTreeItemOnInputTextKeyPressWhenKeyIsNotEnter() {
final KeyDownEvent event = mock(KeyDownEvent.class);
final NativeEvent nativeEvent = mock(NativeEvent.class);
when(event.getNativeEvent()).thenReturn(nativeEvent);
when(nativeEvent.getKeyCode()).thenReturn(99);
treeItem.onInputTextKeyPress(event);
verify(treeItem, never()).save();
}
Aggregations