Package com.google.collide.client.search.awesomebox.shared.ShortcutManager

Examples of com.google.collide.client.search.awesomebox.shared.ShortcutManager.ShortcutPressedCallback


   * Initializes the shortcut manager with our shortcuts of interest. The
   * {@link ComponentHost} will handle actually notifying us of shortcuts being
   * used.
   */
  private void setupShortcuts() {
    shortcutManager.addShortcut(0, KeyCode.ENTER, new ShortcutPressedCallback() {
      @Override
      public void onShortcutPressed(KeyboardEvent event) {
        event.preventDefault();

        if (searchModel != null) {
          searchModel.getMatchManager().selectNextMatch();
        }
      }
    });

    shortcutManager.addShortcut(ModifierKeys.SHIFT, KeyCode.ENTER, new ShortcutPressedCallback() {
      @Override
      public void onShortcutPressed(KeyboardEvent event) {
        event.preventDefault();

        if (searchModel != null) {
          searchModel.getMatchManager().selectPreviousMatch();
        }
      }
    });

    shortcutManager.addShortcut(ModifierKeys.ACTION, KeyCode.G, new ShortcutPressedCallback() {
      @Override
      public void onShortcutPressed(KeyboardEvent event) {
        event.preventDefault();

        if (focusManager != null) {
          focusManager.focus();
        }
      }
    });

    shortcutManager.addShortcut(
        ModifierKeys.ACTION | ModifierKeys.SHIFT, KeyCode.G, new ShortcutPressedCallback() {
          @Override
          public void onShortcutPressed(KeyboardEvent event) {
            event.preventDefault();
            searchModel.getMatchManager().selectPreviousMatch();

View Full Code Here


    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);
    callback.onShortcutPressed(fourthKey);
    EasyMock.replay(callback);

    shortcutManager.addShortcut(ModifierKeys.ALT, KeyCode.A, callback);
    shortcutManager.addShortcut(ModifierKeys.ALT | ModifierKeys.SHIFT, KeyCode.B, callback);
    shortcutManager.addShortcut(
View Full Code Here


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

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

    shortcutManager.addShortcut(ModifierKeys.ALT, KeyCode.A, callback);
    shortcutManager.onKeyDown(firstKey);
    shortcutManager.clearShortcuts();
View Full Code Here

  }

  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);
    secondCallback.onShortcutPressed(firstKey);
    EasyMock.replay(secondCallback);

    shortcutManager.addShortcut(ModifierKeys.ALT, KeyCode.A, callback);
    shortcutManager.addShortcut(ModifierKeys.ALT, KeyCode.A, secondCallback);
    shortcutManager.onKeyDown(firstKey);
View Full Code Here

TOP

Related Classes of com.google.collide.client.search.awesomebox.shared.ShortcutManager.ShortcutPressedCallback

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.