/** * Assert that all shift keys are in the expected state. * * @param event the event that was triggered */ private static void assertAllShiftKeys( Event event, boolean expectedCtrl, boolean expectedAlt, boolean expectedShift, boolean expectedMeta) { assertEquals("Expecting ctrl = " + expectedCtrl, expectedCtrl, event.getCtrlKey()); assertEquals("Expecting alt = " + expectedAlt, expectedAlt, event.getAltKey()); assertEquals("Expecting shift = " + expectedShift, expectedShift, event.getShiftKey()); assertEquals("Expecting meta = " + expectedMeta, expectedMeta, event.getMetaKey()); }
@Override public void onBrowserEvent(Event event) { if (disabled || readonly) { return; } final Element targ = DOM.eventGetTarget(event); if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) { processMouseWheelEvent(event); } else if (dragging || targ == handle) { processHandleEvent(event); } else if (targ == smaller) { decreaseValue(true); } else if (targ == bigger) { increaseValue(true); } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) { processBaseEvent(event); } else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS) || (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) { if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event.getShiftKey())) { feedbackPopup.show(); delayedValueUpdater.trigger(); DOM.eventPreventDefault(event); DOM.eventCancelBubble(event, true); } } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONFOCUS) { feedbackPopup.show(); } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONBLUR) { feedbackPopup.hide(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { feedbackPopup.show(); processBaseEvent(event); } if (Util.isTouchEvent(event)) { event.preventDefault(); // avoid simulated events event.stopPropagation(); } if (client != null) { client.handleTooltipEvent(event, this); } }
private static KeyEvent toKeyEvent(Event e) { Key key = KeyCodeMapper.getKey(e.getKeyCode()); Set<ModifierKey> modifiers = new HashSet<>(); if (e.getCtrlKey()) { modifiers.add(ModifierKey.CONTROL); } if (e.getAltKey()) { modifiers.add(ModifierKey.ALT); } if (e.getShiftKey()) { modifiers.add(ModifierKey.SHIFT); } if (e.getMetaKey()) { modifiers.add(ModifierKey.META); } return new KeyEvent(key, (char) e.getCharCode(), modifiers); }