Package elemental.events

Examples of elemental.events.KeyboardEvent$KeyCode


      }, false);

      getElement().addEventListener(Event.KEYUP, new EventListener() {
        @Override
        public void handleEvent(Event evt) {
          KeyboardEvent event = (KeyboardEvent) evt;
          if (event.getKeyCode() == KeyCode.ESC && getDelegate() != null) {
            getDelegate().onEscapePressed();
          }
        }
      }, false);
    }
View Full Code Here


      public void handleEvent(Event evt) {
        if (!handlerEnabled) {
          return;
        }

        KeyboardEvent event = (KeyboardEvent) evt;
        if (event.getKeyCode() == KeyCode.DOWN) {
          list.selectNext();
          evt.preventDefault();
        } else if (event.getKeyCode() == KeyCode.UP) {
          list.selectPrevious();
          evt.preventDefault();
        } else if (event.getKeyCode() == KeyCode.ENTER) {
          list.handleClick();
        }
      }
    }, false);
  }
View Full Code Here

      });

      Elements.asJsElement(awesomeBoxInput).setOnKeyDown(new EventListener() {
        @Override
        public void handleEvent(Event event) {
          KeyboardEvent keyEvent = (KeyboardEvent) event;

          if (getDelegate() != null) {
            getDelegate().onInputKeyDown(keyEvent);
          }
        }
      });

      Elements.asJsElement(closeButton).setOnClick(new EventListener() {
        @Override
        public void handleEvent(Event arg0) {
          getDelegate().onCloseClicked();
        }
      });

      getElement().setOnKeyUp(new EventListener() {
        @Override
        public void handleEvent(Event event) {
          KeyboardEvent keyEvent = (KeyboardEvent) event;
          if (getDelegate() != null) {
            getDelegate().onKeyUp(keyEvent);
          }
        }
      });
View Full Code Here

        }
      };

      @Override
      public void handleEvent(Event evt) {
        KeyboardEvent event = (KeyboardEvent) evt;

        if (inputBox.getValue().length() < minimumCharactersBeforeCompletion) {
          dropdown.hide();
        } else {
          deferredShow.cancel();
          deferredShow.schedule(AUTOCOMPLETE_DELAY);
        }
      }
    }, false);

    inputBox.addEventListener(Event.BLUR, new EventListener() {
      @Override
      public void handleEvent(Event evt) {
        dropdown.hide();
      }
    }, false);

    inputBox.addEventListener(Event.KEYUP, new EventListener() {
      @Override
      public void handleEvent(Event evt) {
        KeyboardEvent event = (KeyboardEvent) evt;

        if (event.getKeyCode() == KeyCode.ESC) {
          dropdown.hide();
        }
      }
    }, false);
View Full Code Here

      EventListener onEnterListener = new EventListener() {
        @Override
        public void handleEvent(Event evt) {
          if (getDelegate() != null) {
            KeyboardEvent keyEvent = (KeyboardEvent) evt;
            if (keyEvent.getKeyCode() == KeyboardEvent.KeyCode.ENTER) {
              getDelegate().onPathInputChanged();
              evt.stopPropagation();
              hide();
            }
          }
View Full Code Here

     */
    final EventRemover eventRemover =
        Elements.getBody().addEventListener(Event.KEYDOWN, new EventListener() {
          @Override
          public void handleEvent(Event evt) {
            KeyboardEvent event = (KeyboardEvent) evt;
            if (event.isAltKey() && event.getKeyCode() == KeyCode.ENTER) {
              appContext.getAwesomeBoxComponentHostModel().revertToDefaultComponent();
              header.getAwesomeBoxComponentHost().show();
            }
          }
        }, true);
View Full Code Here

*/
public class MappedShortcutManagerTest extends TestCase {
  ShortcutManager shortcutManager;

  private KeyboardEvent expectKeyboard(int modifiers, int keyCode, int charCode) {
    KeyboardEvent keyEvent = EasyMock.createMock(KeyboardEvent.class);
    EasyMock.expect(keyEvent.getKeyCode()).andReturn(keyCode).anyTimes();
    EasyMock.expect(keyEvent.getCharCode()).andReturn(charCode).anyTimes();
    EasyMock.expect(keyEvent.isAltKey()).andReturn(
        (modifiers & ModifierKeys.ALT) == ModifierKeys.ALT).anyTimes();
    EasyMock.expect(keyEvent.isCtrlKey()).andReturn(
        (modifiers & ModifierKeys.ACTION) == ModifierKeys.ACTION).anyTimes();
    EasyMock.expect(keyEvent.isMetaKey()).andReturn(
        (modifiers & ModifierKeys.ACTION) == ModifierKeys.ACTION).anyTimes();
    EasyMock.expect(keyEvent.isShiftKey()).andReturn(
        (modifiers & ModifierKeys.SHIFT) == ModifierKeys.SHIFT).anyTimes();
    EasyMock.replay(keyEvent);
    return keyEvent;
  }
View Full Code Here

  public void setUp() {
    shortcutManager = new MappedShortcutManager();
  }

  public void testShortcutCallbackCalled() {
    KeyboardEvent firstKey = expectKeyboard(ModifierKeys.ALT, KeyCode.A, 'a');
    KeyboardEvent secondKey = expectKeyboard(ModifierKeys.ALT | ModifierKeys.SHIFT, KeyCode.B, 'B');
    KeyboardEvent thirdKey =
        expectKeyboard(ModifierKeys.ALT | ModifierKeys.SHIFT | ModifierKeys.ACTION, KeyCode.B, 'B');
    KeyboardEvent fourthKey = expectKeyboard(0, KeyCode.A, 'a');

    ShortcutPressedCallback callback = EasyMock.createMock(ShortcutPressedCallback.class);
    callback.onShortcutPressed(firstKey);
    callback.onShortcutPressed(secondKey);
    callback.onShortcutPressed(thirdKey);
View Full Code Here

    EasyMock.verify(callback);
  }


  public void testClearShortcuts() {
    KeyboardEvent firstKey = expectKeyboard(ModifierKeys.ALT, KeyCode.A, 'a');

    ShortcutPressedCallback callback = EasyMock.createMock(ShortcutPressedCallback.class);
    callback.onShortcutPressed(firstKey);
    EasyMock.replay(callback);
View Full Code Here

    EasyMock.verify(callback);
  }

  public void testExistingShortcutAddedCausesLastOneToRun() {
    KeyboardEvent firstKey = expectKeyboard(ModifierKeys.ALT, KeyCode.A, 'a');

    ShortcutPressedCallback callback = EasyMock.createMock(ShortcutPressedCallback.class);
    EasyMock.replay(callback);

    ShortcutPressedCallback secondCallback = EasyMock.createMock(ShortcutPressedCallback.class);
View Full Code Here

TOP

Related Classes of elemental.events.KeyboardEvent$KeyCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.