Search in sources :

Example 16 with KeyboardEvent

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);
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 17 with KeyboardEvent

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();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) KeyboardEvent(elemental2.dom.KeyboardEvent) Event(org.jboss.errai.common.client.dom.Event) Test(org.junit.Test)

Example 18 with KeyboardEvent

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();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) KeyboardEvent(elemental2.dom.KeyboardEvent) Event(org.jboss.errai.common.client.dom.Event) Test(org.junit.Test)

Example 19 with KeyboardEvent

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);
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 20 with KeyboardEvent

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();
        }
    }
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent)

Aggregations

KeyboardEvent (elemental2.dom.KeyboardEvent)21 Test (org.junit.Test)16 Event (org.jboss.errai.common.client.dom.Event)2 Button (org.jboss.errai.common.client.dom.Button)1