use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImpl method typeSelectorKeyDownEventListener.
void typeSelectorKeyDownEventListener(final Object event) {
if (event instanceof KeyboardEvent) {
final KeyboardEvent keyEvent = (KeyboardEvent) event;
if (isEnterKeyPressed(keyEvent)) {
hide(true);
keyEvent.preventDefault();
onClosedByKeyboard();
} else if (isEscapeKeyPressed(keyEvent)) {
reset();
hide(false);
onClosedByKeyboard();
} else if (isTabKeyPressed(keyEvent)) {
if (keyEvent.shiftKey) {
final Button manageButton = getManageButton();
manageButton.focus();
} else {
valueEditor.focus();
}
keyEvent.preventDefault();
}
}
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerEscKey.
@Test
public void testTypeSelectorKeyDownEventListenerEscKey() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
doReturn(true).when(view).isEscapeKeyPressed(keyboardEvent);
final ValueAndDataTypePopoverViewImpl.BootstrapSelectDropDownMonitor monitor = mock(ValueAndDataTypePopoverViewImpl.BootstrapSelectDropDownMonitor.class);
doReturn(monitor).when(view).getMonitor();
final elemental2.dom.Element menuElement = mock(elemental2.dom.Element.class);
doReturn(menuElement).when(monitor).getMenuElement();
view.typeSelectorKeyDownEventListener(keyboardEvent);
verify(view).reset();
verify(view).hide(false);
verify(view).onClosedByKeyboard();
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testIsEscapeKeyPressed.
@Test
public void testIsEscapeKeyPressed() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
keyboardEvent.key = ESC_KEY;
boolean actual = view.isEscapeKeyPressed(keyboardEvent);
assertTrue(actual);
keyboardEvent.key = "A";
actual = view.isEscapeKeyPressed(keyboardEvent);
assertFalse(actual);
keyboardEvent.key = ESCAPE_KEY;
actual = view.isEscapeKeyPressed(keyboardEvent);
assertTrue(actual);
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testIsEnterKeyPressed.
@Test
public void testIsEnterKeyPressed() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
keyboardEvent.key = ENTER_KEY;
boolean actual = view.isEnterKeyPressed(keyboardEvent);
assertTrue(actual);
keyboardEvent.key = "A";
actual = view.isEnterKeyPressed(keyboardEvent);
assertFalse(actual);
}
use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testManagerButtonKeyDownEventWhenIsNotEscapeKey.
@Test
public void testManagerButtonKeyDownEventWhenIsNotEscapeKey() {
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(false).when(view).isEscapeKeyPressed(keyboardEvent);
view.manageButtonKeyDownEventListener(keyboardEvent);
verify(view, never()).hide(false);
verify(view, never()).reset();
verify(view, never()).onClosedByKeyboard();
}
Aggregations