Search in sources :

Example 71 with Event

use of elemental2.dom.Event 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 72 with Event

use of elemental2.dom.Event 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 73 with Event

use of elemental2.dom.Event 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 74 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class AbstractPopoverViewImplTest method testKeyDownEventListenerWhenIsNotKeyboardEvent.

@Test
public void testKeyDownEventListenerWhenIsNotKeyboardEvent() {
    final Event event = mock(Event.class);
    view.keyDownEventListener(event);
    verify(view, never()).hide();
    verify(event, never()).stopPropagation();
    verify(view, never()).onClosedByKeyboard();
    verify(view, never()).isEscapeKeyPressed(any());
    verify(view, never()).reset();
}
Also used : Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 75 with Event

use of elemental2.dom.Event 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

Test (org.junit.Test)50 HTMLElement (elemental2.dom.HTMLElement)27 Event (elemental2.dom.Event)26 KeyboardEvent (elemental2.dom.KeyboardEvent)19 Element (elemental2.dom.Element)18 MouseEvent (elemental2.dom.MouseEvent)16 HTMLDivElement (elemental2.dom.HTMLDivElement)15 HTMLInputElement (elemental2.dom.HTMLInputElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)7 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)7 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)7 DOMRect (elemental2.dom.DOMRect)5 DOMTokenList (elemental2.dom.DOMTokenList)5 DomGlobal (elemental2.dom.DomGlobal)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4