use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class DataTypeShortcuts method keyDownListener.
void keyDownListener(final Event e) {
if (!(e instanceof KeyboardEvent)) {
return;
}
final KeyboardEvent event = (KeyboardEvent) e;
if (isNotEnabled()) {
return;
}
switch(event.key) {
case "Esc":
/* IE/Edge specific value */
case "Escape":
listShortcuts.onEscape();
return;
case "Backspace":
if (event.ctrlKey) {
listShortcuts.onCtrlBackspace();
}
return;
case "Tab":
if (isSearchBarTarget(event)) {
event.preventDefault();
listShortcuts.onTab();
}
return;
case "s":
if (event.ctrlKey) {
event.preventDefault();
listShortcuts.onCtrlS();
}
return;
case "b":
if (event.ctrlKey) {
event.preventDefault();
listShortcuts.onCtrlB();
}
return;
case "u":
if (event.ctrlKey) {
event.preventDefault();
listShortcuts.onCtrlU();
}
return;
case "d":
if (event.ctrlKey) {
event.preventDefault();
listShortcuts.onCtrlD();
}
return;
case "e":
if (event.ctrlKey) {
event.preventDefault();
listShortcuts.onCtrlE();
}
return;
}
if (isInputEvent(event) && !isSearchBarTarget(event)) {
return;
}
switch(event.key) {
case "Down":
/* IE/Edge specific value */
case "ArrowDown":
listShortcuts.onArrowDown();
return;
case "Up":
/* IE/Edge specific value */
case "ArrowUp":
listShortcuts.onArrowUp();
return;
case "Left":
/* IE/Edge specific value */
case "ArrowLeft":
listShortcuts.onArrowLeft();
return;
case "Right":
/* IE/Edge specific value */
case "ArrowRight":
listShortcuts.onArrowRight();
}
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImpl method manageButtonKeyDownEventListener.
void manageButtonKeyDownEventListener(final Object event) {
if (event instanceof KeyboardEvent) {
final KeyboardEvent keyEvent = (KeyboardEvent) event;
if (isEscapeKeyPressed(keyEvent)) {
reset();
hide(false);
onClosedByKeyboard();
}
}
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerWhenIsNotAHandledKey.
@Test
public void testKeyDownEventListenerWhenIsNotAHandledKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doReturn(false).when(view).isEnterKeyPressed(event);
doReturn(false).when(view).isEscapeKeyPressed(event);
view.keyDownEventListener(event);
verify(view, never()).hide();
verify(event, never()).stopPropagation();
verify(view, never()).onClosedByKeyboard();
verify(view, never()).reset();
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerEscKey.
@Test
public void testKeyDownEventListenerEscKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doNothing().when(view).hide();
doNothing().when(view).reset();
doNothing().when(view).onClosedByKeyboard();
doReturn(false).when(view).isEnterKeyPressed(event);
doReturn(true).when(view).isEscapeKeyPressed(event);
view.keyDownEventListener(event);
verify(view).hide();
verify(view).reset();
verify(view).onClosedByKeyboard();
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerEnterKey.
@Test
public void testTypeSelectorKeyDownEventListenerEnterKey() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(true).when(view).isEnterKeyPressed(keyboardEvent);
doNothing().when(view).hide(true);
view.typeSelectorKeyDownEventListener(keyboardEvent);
verify(view).hide(true);
verify(keyboardEvent).preventDefault();
verify(view).onClosedByKeyboard();
}
Aggregations