use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testIsTabKeyPressed.
@Test
public void testIsTabKeyPressed() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
keyboardEvent.key = TAB_KEY;
boolean actual = view.isTabKeyPressed(keyboardEvent);
assertTrue(actual);
keyboardEvent.key = "A";
actual = view.isTabKeyPressed(keyboardEvent);
assertFalse(actual);
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ListSelectorViewImplTest method testOnKeyDownWhenEscapeIsPressedOnIEOrEdge.
@Test
public void testOnKeyDownWhenEscapeIsPressedOnIEOrEdge() {
final Event event = mock(Event.class);
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(keyboardEvent).when(view).asElemental2Event(event);
keyboardEvent.key = "Esc";
view.onKeyDown().call(event);
verify(view).hide();
verify(view).returnFocusToPanel();
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ListSelectorViewImplTest method testOnKeyDownWhenEscapeIsPressedOnOtherBrowser.
@Test
public void testOnKeyDownWhenEscapeIsPressedOnOtherBrowser() {
final Event event = mock(Event.class);
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(keyboardEvent).when(view).asElemental2Event(event);
keyboardEvent.key = "Escape";
view.onKeyDown().call(event);
verify(view).hide();
verify(view).returnFocusToPanel();
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerEnterKey.
@Test
public void testKeyDownEventListenerEnterKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doNothing().when(view).hide();
doNothing().when(view).onClosedByKeyboard();
doReturn(true).when(view).isEnterKeyPressed(event);
view.keyDownEventListener(event);
verify(view).hide();
verify(event).stopPropagation();
verify(view).onClosedByKeyboard();
verify(view, never()).isEscapeKeyPressed(event);
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImpl method keyDownEventListener.
public void keyDownEventListener(final Object event) {
if (event instanceof KeyboardEvent) {
final KeyboardEvent keyEvent = (KeyboardEvent) event;
if (isEnterKeyPressed(keyEvent)) {
hide();
keyEvent.stopPropagation();
onClosedByKeyboard();
} else if (isEscapeKeyPressed(keyEvent)) {
reset();
hide();
onClosedByKeyboard();
}
}
}
Aggregations