Java Code Examples for com.google.gwt.event.dom.client.KeyCodes

The following are top voted examples for showing how to use com.google.gwt.event.dom.client.KeyCodes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: sc2gears   File: ClientUtils.java   View source code 7 votes vote down vote up
/**
 * Adds a {@link KeyPressHandler} to the specified widget which calls {@link Button#click()} on <code>targetButton</code>
 * when the Enter key is pressed.
 * @param widget       widget to add the key handler to
 * @param targetButton target button to activate when the enter key is pressed
 */
public static void addEnterTarget( final HasKeyPressHandlers widget, final Button targetButton ) {
	widget.addKeyPressHandler( new KeyPressHandler() {
		@Override
		public void onKeyPress( final KeyPressEvent event ) {
			if ( event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER )
				targetButton.click();
		}
	} );
}
 
Example 2
Project: appformer   File: EntitiesExplorerViewImpl.java   View source code 7 votes vote down vote up
@Override
public EntitiesExplorerView configure(final String entityType,
                                      final EntitiesList.View entitiesListView) {
    this.entitiesListView = entitiesListView;
    this.entityType = entityType;

    initWidget(uiBinder.createAndBindUi(this));
    searchBox.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                doSearch(searchBox.getText());
            }
        }
    });
    searchButton.addClickHandler(e -> doSearch(searchBox.getText()));

    clearSearchButton.addDomHandler(new ClickHandler() {
                                        @Override
                                        public void onClick(final ClickEvent clickEvent) {
                                            doSearch("");
                                        }
                                    },
                                    ClickEvent.getType());
    clearSearch();
    return this;
}
 
Example 3
Project: sig-seguimiento-vehiculos   File: ToggleTool.java   View source code 6 votes vote down vote up
private KeyUpHandler setEscapeHandler() {
	KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode()) {
				for (Control control : controls) {
					try {
						((DrawFeature) control).cancel();
					} catch (Exception e) {
						LOGGER.error("ACTION CANCELED: "
								+ control.getControlId());
					}
				}
			}
		}
	};
	return handler;
}
 
Example 4
Project: sig-seguimiento-vehiculos   File: ToggleTool.java   View source code 6 votes vote down vote up
private KeyUpHandler setUndoHandler() {
	final KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_U == event.getNativeEvent().getKeyCode()) {
				for (final Control control : controls) {
					try {
						((DrawFeature) control).undo();
					} catch (Exception e) {
						LOGGER.error(
								"ACTION UNDO: " + control.getControlId(), e);
					}
				}
			}
		}
	};
	return handler;
}
 
Example 5
Project: sig-seguimiento-vehiculos   File: ToggleTool.java   View source code 6 votes vote down vote up
private KeyUpHandler setRedoHandler() {
	final KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_R == event.getNativeEvent().getKeyCode()) {
				for (final Control control : controls) {
					try {
						((DrawFeature) control).redo();
					} catch (Exception e) {
						LOGGER.error("ACTION REDO: "
								+ control.getControlId());
					}
				}
			}
		}
	};
	return handler;
}
 
Example 6
Project: cuba   File: EscKeyDownHandler.java   View source code 6 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent keyDownEvent) {

    if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {

        SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class);

        if (panel != null) {
            WidgetUtil.focus(panel.getParent().getElement());

            // prevent further bubbling of the event as it has only
            // navigational purpose if thrown at this depth. A subsequent
            // press of ESC is not stopped, so ESC abort actions of the
            // application should work as soon as the focus is in
            // "navigational mode" on a grid-cell
            keyDownEvent.preventDefault();
            keyDownEvent.stopPropagation();
        }
    }
}
 
Example 7
Project: cuba   File: CubaNotification.java   View source code 6 votes vote down vote up
@Override
public boolean onEventPreview(Event event) {
    int type = DOM.eventGetType(event);

    if ((type == Event.ONCLICK || type == Event.ONTOUCHEND)
            && event.getEventTarget() != null) {
        Element target = Element.as(event.getEventTarget());
        if (target.getClassName() != null && target.getClassName().contains(CUBA_NOTIFICATION_MODALITY_CURTAIN)) {
            hide();
            return false;
        }
    }

    if (type == Event.ONKEYDOWN && event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
        if (!getElement().getClassName().contains(TRAY_STYLE)) {
            hide();
            return false;
        }
    }

    return super.onEventPreview(event);
}
 
Example 8
Project: Wiab.pro   File: EditorEventImpl.java   View source code 6 votes vote down vote up
@Override
public boolean shouldTrackCursor() {
  if (isMouseButtonEvent()) {
    return true;
  }
  if (isKeyEvent()) {
    KeySignalType keySignalType = getKeySignalType();
    // The cursor location should move if the user either has modified the
    // content (typed or delete), or move the cursor deliberately.  However, page up/down
    // doesn't actually move the cursor, so we don't want to move the view port
    int keyCode = getKeyCode();
    return keySignalType == KeySignalType.INPUT ||
          keySignalType == KeySignalType.DELETE ||
          keySignalType == KeySignalType.NAVIGATION && (
             keyCode != KeyCodes.KEY_PAGEDOWN &&
             keyCode != KeyCodes.KEY_PAGEUP);
  }
  return false;    
}
 
Example 9
Project: Wiab.pro   File: EditorEventHandler.java   View source code 6 votes vote down vote up
private boolean handleEventsManuallyOnNode(EditorEvent event, Point<ContentNode> caret)
    throws SelectionLostException {
  // Note that caret may be null if this is called during typing extraction

  // Always handle enter specially, and always cancel the default action.
  // TODO(danilatos): This is still a slight anomaly, to call a
  // node.handleXYZ method here.
  if (event.isOnly(KeyCodes.KEY_ENTER)) {
    refreshEditorWithCaret(event);
    caret = event.getCaret().asPoint();
    editorInteractor.checkpoint(new FocusedContentRange(caret));
    router.handleEnter(caret.getContainer(), event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return true;
  } else if (event.isCombo(KeyCodes.KEY_ENTER, KeyModifier.SHIFT)) {
    // shift+enter inserts a "newline" (such as a <br/>) by default
    // TODO(danilatos): Form elements want to handle this.
    return true;
  }
  return false;
}
 
Example 10
Project: Wiab.pro   File: EditorEventHandler.java   View source code 6 votes vote down vote up
private boolean handleNavigationKeyEvents(EditorEvent event) {
  editorInteractor.checkpoint(null);
  editorInteractor.clearCaretAnnotations();
  ContentNode node = cachedSelection.getFocus().getContainer();
  logger.trace().log("Navigation event");

  // Not using key combo, because we want to handle left key with
  // any modifiers also applying.
  // TODO(danilatos): MoveUnit, and holding down shift for selection.
  if (event.getKeyCode() == KeyCodes.KEY_LEFT) {
    router.handleLeft(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_RIGHT);
    return !event.shouldAllowBrowserDefault();
  } else if (event.getKeyCode() == KeyCodes.KEY_RIGHT) {
    router.handleRight(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return !event.shouldAllowBrowserDefault();
  } else {
    editorInteractor.rebiasSelection(CursorDirection.NEUTRAL);
  }
  return false;
}
 
Example 11
Project: Wiab.pro   File: EditorEventHandlerGwtTest.java   View source code 6 votes vote down vote up
public void testDeleteWithRangeSelectedDeletesRange() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.DELETE, KeyCodes.KEY_LEFT);

  //Event event = Document.get().createKeyPressEvent(
  //    false, false, false, false, KeyCodes.KEY_BACKSPACE, 0).cast();

  Text input = Document.get().createTextNode("ABCDE");
  ContentNode node = new ContentTextNode(input, null);

  final Point<ContentNode> start = Point.inText(node, 1);
  final Point<ContentNode> end = Point.inText(node, 4);
  FakeEditorInteractor interactor = setupFakeEditorInteractor(
      new FocusedContentRange(start, end));
  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.DELETE_RANGE).nOf(1).withArgs(
      start, end, false).returns(start);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
Example 12
Project: ephesoft   File: AboutDialog.java   View source code 6 votes vote down vote up
@Override
protected void onPreviewNativeEvent(NativePreviewEvent preview) {
	super.onPreviewNativeEvent(preview);

	NativeEvent evt = preview.getNativeEvent();
	if (evt.getType().equals("keydown")) {
		// Use the popup's key preview hooks to close the dialog when either
		// enter or escape is pressed.
		switch (evt.getKeyCode()) {
		case KeyCodes.KEY_ENTER:
		case KeyCodes.KEY_ESCAPE:
			hide();
			break;
		default:
			break;
		}
	}
}
 
Example 13
Project: gwt-chronoscope   File: AbstractEventHandler.java   View source code 6 votes vote down vote up
/**
 * Handles TAB key and Shift-TAB key presses.
 */
protected boolean handleTabKey(Event event, ChartState chartInfo, int keyCode,
    boolean isShiftKeyDown) {
  if (DOM.eventGetType(event) != chartInfo.getTabKeyEventCode()) {
    return false;
  }

  if (keyCode == KeyCodes.KEY_TAB) {
    if (isShiftKeyDown) {
      chartInfo.chart.prevFocus();
    } else {
      chartInfo.chart.nextFocus();
    }
    return true;
  }

  return false;
}
 
Example 14
Project: appformer   File: BaseGridWidgetKeyboardHandlerTest.java   View source code 6 votes vote down vote up
@Test
public void enterKeyEditsCells() {
    when(layer.getGridWidgets()).thenReturn(gridWidgets);
    when(gridWidget1.isSelected()).thenReturn(true);
    when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER);

    gridWidget1Data.selectCell(0,
                               0);

    handler.onKeyDown(event);

    verify(gridWidget1,
           times(1)).startEditingCell(eq(0),
                                      eq(0));
    verify(layer,
           never()).draw();
    verify(keyboardOperationEditCell,
           times(1)).perform(eq(gridWidget1),
                             eq(false),
                             eq(false));
}
 
Example 15
Project: gwt-chronoscope   File: ChartKeyPressHandler.java   View source code 6 votes vote down vote up
public void onKeyPress(KeyPressEvent event) {
  ChartState chartInfo = getChartState(event);

  Chart chart = chartInfo.chart;

  int keyCode = event.getCharCode();
  boolean handled = true;
  if (keyCode == KeyCodes.KEY_TAB) {
    handled = handleTabKey((Event)event.getNativeEvent(), chartInfo, keyCode, event.isShiftKeyDown());
  } else if (keyCode == KEY_Z) {
    chart.nextZoom();
  } else if (keyCode == KEY_X) {
    chart.prevZoom();
  } else if (keyCode == KeyCodes.KEY_ENTER) {
    chart.maxZoomToFocus();
  } else {
    handled = false;
  }

  chartInfo.setHandled(handled);
  if (handled) {
      event.stopPropagation();
      event.preventDefault();
  }
}
 
Example 16
Project: hawkbit   File: AutoCompleteTextFieldConnector.java   View source code 6 votes vote down vote up
@Override
protected void extend(final ServerConnector target) {
    textFieldWidget = (VTextField) ((ComponentConnector) target).getWidget();
    textFieldWidget.setImmediate(true);
    textFieldWidget.textChangeEventMode = "EAGER";
    panel.setWidget(select);
    panel.setStyleName("suggestion-popup");
    panel.setOwner(textFieldWidget);

    textFieldWidget.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(final KeyUpEvent event) {
            if (panel.isAttached()) {
                handlePanelEventDelegation(event);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                rpc.executeQuery(textFieldWidget.getValue(), textFieldWidget.getCursorPos());
            } else {
                doAskForSuggestion();
            }
        }
    });
}
 
Example 17
Project: hawkbit   File: AutoCompleteTextFieldConnector.java   View source code 6 votes vote down vote up
private void handlePanelEventDelegation(final KeyUpEvent event) {
    switch (event.getNativeKeyCode()) {
    case KeyCodes.KEY_DOWN:
        arrowKeyDown(event);
        break;
    case KeyCodes.KEY_UP:
        arrorKeyUp(event);
        break;
    case KeyCodes.KEY_ESCAPE:
        escapeKey();
        break;
    case KeyCodes.KEY_ENTER:
        enterKey();
        break;
    default:
        doAskForSuggestion();
    }
}
 
Example 18
Project: che   File: CategoriesPageViewImpl.java   View source code 6 votes vote down vote up
@UiHandler("projectName")
void onProjectNameChanged(KeyUpEvent event) {
  if (projectName.getValue() != null && projectName.getValue().contains(" ")) {
    String tmp = projectName.getValue();
    while (tmp.contains(" ")) {
      tmp = tmp.replaceAll(" ", "-");
    }
    projectName.setValue(tmp);
  }

  if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
    return;
  }

  delegate.projectNameChanged(projectName.getText());
}
 
Example 19
Project: mvp4g-examples   File: AboutDialog.java   View source code 6 votes vote down vote up
@Override
protected void onPreviewNativeEvent(NativePreviewEvent preview) {
  super.onPreviewNativeEvent(preview);

  NativeEvent evt = preview.getNativeEvent();
  if (evt.getType()
         .equals("keydown")) {
    // Use the popup's key preview hooks to close the dialog when either
    // enter or escape is pressed.
    switch (evt.getKeyCode()) {
      case KeyCodes.KEY_ENTER:
      case KeyCodes.KEY_ESCAPE:
        hide();
        break;
    }
  }
}
 
Example 20
Project: che   File: GithubImporterPageViewImpl.java   View source code 6 votes vote down vote up
@UiHandler("projectDescription")
void onProjectDescriptionChanged(KeyUpEvent event) {
  if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
    return;
  }
  delegate.onProjectDescriptionChanged(projectDescription.getValue());
}
 
Example 21
Project: djvu-html5   File: SinglePageLayout.java   View source code 6 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
	int key = event.getNativeKeyCode();
	if (event.isControlKeyDown()) {
		if (key == KEY_PLUS || key == KEY_MINUS) {
			app.getToolbar().zoomChangeClicked(key == KEY_PLUS ? 1 : -1);
			event.preventDefault();
		}
	} else if (!event.isShiftKeyDown()) {
		boolean handled = true;
		switch (key) {
		case KeyCodes.KEY_HOME:
			changePage(0, -1, -1);
			break;
		case KeyCodes.KEY_END:
			changePage(dataStore.getPageCount() - 1, 1, 1);
			break;
		default:
			handled = false;
		}
		if (handled)
			event.preventDefault();
	}
}
 
Example 22
Project: easy-vote   File: ElectionWidget.java   View source code 6 votes vote down vote up
public void onKeyPress(KeyPressEvent arg0) {
	if (arg0.getCharCode() == KeyCodes.KEY_ENTER) {
		
		Long candidateID = null;
		
		try{
			candidateID = Long.parseLong(addCandidateIdTB.getText());
		}  catch(NumberFormatException e) {
			BallotServer.popError("The Candidate ID must be a number.");
			return;
		}
		
		Communicator.getInstance().getService().addCandidate(electionId, 
				addCandidateNameTB.getText(), candidateID,
				new UpdateCallback());
	}
}
 
Example 23
Project: geowe-core   File: ToggleTool.java   View source code 6 votes vote down vote up
private KeyUpHandler setUndoHandler() {
	final KeyUpHandler handler = new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_U == event.getNativeEvent().getKeyCode()) {
				for (final Control control : controls) {
					try {
						((DrawFeature) control).undo();
					} catch (Exception e) {
						LOGGER.error(
								"ACTION UNDO: " + control.getControlId(), e);
					}
				}
			}
		}
	};
	return handler;
}
 
Example 24
Project: fullmetalgalaxy   File: DlgChatInput.java   View source code 6 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent p_event)
{
  switch( p_event.getNativeKeyCode() )
  {
  case KeyCodes.KEY_ESCAPE:
    hide();
    p_event.stopPropagation();
    break;
  case KeyCodes.KEY_ENTER:
    sendMessage();
    p_event.stopPropagation();
    p_event.getNativeEvent().stopPropagation();
    break;
  default:
    break;
  }
}
 
Example 25
Project: gerrit   File: Hashtags.java   View source code 6 votes vote down vote up
public Hashtags() {

    initWidget(uiBinder.createAndBindUi(this));

    hashtagTextBox.setVisibleLength(VISIBLE_LENGTH);
    hashtagTextBox.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent e) {
            if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
              onCancel(null);
            } else if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
              onAdd(null);
            }
          }
        });

    addHashtagIcon.addDomHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            onOpenForm();
          }
        },
        ClickEvent.getType());
  }
 
Example 26
Project: firefly   File: PagingPanel.java   View source code 6 votes vote down vote up
/**
 * Create a box that holds the current page.
 */
private void createCurPageBox() {
    // Setup the widget
    curPageBox.setWidth("3em");
    curPageBox.setText("1");
    curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);

    // Disallow non-numeric pages
    KeyPressHandler handler = new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {

            int keyCode = event.getNativeEvent().getKeyCode();
            char charCode = event.getCharCode();
            if (keyCode == KeyCodes.KEY_ENTER) {
                PagingPanel.this.table.gotoPage(getPagingBoxValue(), false);
            } else if (charCode != 0 && !Character.isDigit(charCode)) {
                    curPageBox.cancelKey();
            }
        }
    };

    // Add the handler
    curPageBox.addKeyPressHandler(handler);
}
 
Example 27
Project: appformer   File: BaseGridWidgetKeyboardHandlerTest.java   View source code 6 votes vote down vote up
@Test
public void homeKeyMovesToTopLeft() {
    when(layer.getGridWidgets()).thenReturn(gridWidgets);
    when(gridWidget1.isSelected()).thenReturn(true);
    when(gridWidget1.selectCell(eq(0),
                                eq(0),
                                any(Boolean.class),
                                any(Boolean.class))).thenReturn(true);
    when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_HOME);

    handler.onKeyDown(event);

    verify(gridWidget1,
           times(1)).selectCell(eq(0),
                                eq(0),
                                eq(false),
                                eq(false));
    verify(layer,
           times(1)).draw();
    verify(keyboardOperationSelectTopLeftCell,
           times(1)).perform(eq(gridWidget1),
                             eq(false),
                             eq(false));
}
 
Example 28
Project: gerrit   File: SideBySide.java   View source code 6 votes vote down vote up
@Override
public void registerKeys() {
  super.registerKeys();

  getKeysNavigation()
      .add(
          new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_LEFT, PatchUtil.C.focusSideA()),
          new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_RIGHT, PatchUtil.C.focusSideB()));
  getKeysAction()
      .add(
          new KeyCommand(KeyCommand.M_SHIFT, 'a', PatchUtil.C.toggleSideA()) {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              diffTable.toggleA().run();
            }
          });

  registerHandlers();
}
 
Example 29
Project: gerrit   File: HintTextBox.java   View source code 6 votes vote down vote up
private void onKey(int key) {
  if (key == KeyCodes.KEY_ESCAPE) {
    setText(prevText);

    Widget p = getParent();
    if (p instanceof SuggestBox) {
      // Since the text was changed, ensure that the SuggestBox is
      // aware of this change so that it will refresh properly on
      // the next keystroke.  Without this, if the first keystroke
      // recreates the same string as before ESC was pressed, the
      // SuggestBox will think that the string has not changed, and
      // it will not yet provide any Suggestions.
      ((SuggestBox) p).showSuggestionList();

      // The suggestion list lingers if we don't hide it.
      ((DefaultSuggestionDisplay) ((SuggestBox) p).getSuggestionDisplay()).hideSuggestions();
    }

    setFocus(false);
  }
}
 
Example 30
Project: empiria.player   File: VideoFullScreenHelper.java   View source code 5 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
        event.preventDefault();
        closeFullScreen();
    }

}
 
Example 31
Project: empiria.player   File: BookmarkPopupContents.java   View source code 5 votes vote down vote up
@UiHandler("titleTextBox")
public void titleKeyDownHandler(KeyDownEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
        presenter.applyBookmark();
    } else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
        presenter.discardChanges();
    }
}
 
Example 32
Project: unitimes   File: AriaToggleButton.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (event.getTypeInt() == Event.ONKEYUP && event.getKeyCode() == KeyCodes.KEY_SPACE) {
		onClick();
	}
	if (event.getTypeInt() == Event.ONCLICK) {
		setValue(!getValue());
	}
	super.onBrowserEvent(event);
}
 
Example 33
Project: unitimes   File: UniTimeDialogBox.java   View source code 5 votes vote down vote up
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
	super.onPreviewNativeEvent(event);
	if (isEscapeToHide() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) {
		AriaStatus.getInstance().setText(ARIA.dialogClosed(getText()));
		hide();
	} if (isEnterToSubmit() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
		event.getNativeEvent().stopPropagation();
		event.getNativeEvent().preventDefault();
    	iSubmitHandler.execute();
	}
}
 
Example 34
Project: unitimes   File: CourseFinderCourses.java   View source code 5 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
	if (iCourses.getRowCount() < 2 || iCourses.getData(1) == null) return;
	int row = iCourses.getSelectedRow();
	if (event.getNativeKeyCode() == KeyCodes.KEY_DOWN) {
		if (row < 0 || iCourses.getSelectedRow() + 1 >= iCourses.getRowCount())
			iCourses.setSelected(1, true);
		else
			iCourses.setSelected(row + 1, true);
           scrollToSelectedRow();
           updateCourseDetails();
	} else if (event.getNativeKeyCode()==KeyCodes.KEY_UP) {
		if (row - 1 < 1)
			iCourses.setSelected(iCourses.getRowCount() - 1, true);
		else
			iCourses.setSelected(row - 1, true);
		scrollToSelectedRow();
		updateCourseDetails();
	} else if (event.isControlKeyDown() || event.isAltKeyDown()) {
		for (Map.Entry<Character, Integer> entry: iTabAccessKeys.entrySet())
			if (event.getNativeKeyCode() == Character.toLowerCase(entry.getKey()) || event.getNativeKeyCode() == Character.toUpperCase(entry.getKey())) {
				iCourseDetailsTabBar.selectTab(entry.getValue(), true);
				event.preventDefault();
				event.stopPropagation();
			}
	}
}
 
Example 35
Project: unitimes   File: NumberBox.java   View source code 5 votes vote down vote up
public NumberBox() {
	setStyleName("gwt-SuggestBox");
	setWidth("100px");
	getElement().getStyle().setTextAlign(TextAlign.RIGHT);
	addKeyPressHandler(new KeyPressHandler() {
		@Override
		public void onKeyPress(KeyPressEvent event) {
			if (!isEnabled() || isReadOnly()) return;
			
			int keyCode = event.getNativeEvent().getKeyCode();
			
			switch (keyCode) {
			case KeyCodes.KEY_BACKSPACE:
			case KeyCodes.KEY_DELETE:
			case KeyCodes.KEY_ESCAPE:
			case KeyCodes.KEY_RIGHT:
			case KeyCodes.KEY_LEFT:
			case KeyCodes.KEY_TAB:
				return;
			}

            if (isDecimal() && event.getCharCode() == '.' && !getValue().contains(".")) return;
            if (isNegative() && event.getCharCode() == '-' && !getValue().contains("-") && (getCursorPos() == 0 || getSelectionLength() == getValue().length()))
            	return;

            if (Character.isDigit(event.getCharCode()))
                return;

            cancelKey( );
        }
    } );
}
 
Example 36
Project: unitimes   File: FilterBox.java   View source code 5 votes vote down vote up
private void fixHandlers(final FilterBox box, Widget w) {
	if (w instanceof HasBlurHandlers)
		((HasBlurHandlers)w).addBlurHandler(box.iBlurHandler);
	if (w instanceof HasFocusHandlers)
		((HasFocusHandlers)w).addFocusHandler(box.iFocusHandler);
	if (w instanceof HasKeyDownHandlers)
		((HasKeyDownHandlers)w).addKeyDownHandler(new KeyDownHandler() {
			@Override
			public void onKeyDown(KeyDownEvent event) {
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE)
					if (box.isFilterPopupShowing()) box.hideFilterPopup();
			}
		});
}
 
Example 37
Project: sig-seguimiento-vehiculos   File: CoordinateGeolocationDialog.java   View source code 5 votes vote down vote up
private void addKeyShortcuts() {
	final KeyShortcutHandler keyShortcut = new KeyShortcutHandler(
			getButton(PredefinedButton.OK), KeyCodes.KEY_ENTER);

	latitudTextField.addKeyDownHandler(keyShortcut);
	longitudTextField.addKeyDownHandler(keyShortcut);
}
 
Example 38
Project: sig-seguimiento-vehiculos   File: AttributeSearchDialog.java   View source code 5 votes vote down vote up
private void addKeyShortcuts() {
	KeyShortcutHandler keyShortcut = new KeyShortcutHandler(searchButton,
			KeyCodes.KEY_ENTER);

	layerNameField.addKeyDownHandler(keyShortcut);
	valueAttributeField.addKeyDownHandler(keyShortcut);
	attributeCombo.addKeyDownHandler(keyShortcut);
}
 
Example 39
Project: sig-seguimiento-vehiculos   File: ZoomOutTool.java   View source code 5 votes vote down vote up
private KeyUpHandler createKeyHandler() {
	return new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_PAGEUP == event.getNativeEvent().getKeyCode()) {
				onRelease();
			}
		}
	};
}
 
Example 40
Project: sig-seguimiento-vehiculos   File: ZoomInTool.java   View source code 5 votes vote down vote up
private KeyUpHandler createKeyHandler() {
	KeyUpHandler handler=  new KeyUpHandler() {
		@Override
		public void onKeyUp(final KeyUpEvent event) {
			if (KeyCodes.KEY_PAGEDOWN == event.getNativeEvent().getKeyCode()) {
				onRelease();
			}
		}
	};
	
	return handler;
}