Java 类com.google.gwt.event.dom.client.KeyPressEvent 实例源码

项目:sc2gears    文件:ClientUtils.java   
/**
 * 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();
        }
    } );
}
项目:empiria.player    文件:ReplacingChangeHandlerJUnitTest.java   
@Test
public void replace_foundElement() {
    // given
    TextBoxMock hasValue = mock(TextBoxMock.class);
    when(hasValue.getValue()).thenReturn("a");
    ExpressionReplacer replacer = new ExpressionReplacer();
    replacer.useReplacements(ImmutableMap.of("a", "b", "c", "d"));

    KeyPressEvent event = mock(KeyPressEvent.class);
    when(event.getCharCode()).thenReturn("a".charAt(0));

    ArgumentCaptor<InputEventListener> listenerCaptor = ArgumentCaptor.forClass(InputEventListener.class);
    handler.init(Wrapper.of(hasValue), replacer);
    verify(eventRegistrar).registerInputHandler(eq(hasValue), listenerCaptor.capture());

    // when
    listenerCaptor.getValue().onInput();

    // then
    verify(hasValue).setValue("b", true);
}
项目:Wiab.pro    文件:FocusManager.java   
/**
 * Installs a key handler for key events on this window.
 *
 * @param handler handler to receive key events.
 */
static void install(KeySignalHandler handler) {
  //
  // NOTE: There are three potential candidate elements for sinking keyboard
  // events: the window, the document, and the document body. IE7 does not
  // fire events on the window element, and GWT's RootPanel is already a
  // listener on the body, leaving the document as the only cross-browser
  // whole-window event-sinking 'element'.
  //
  DocumentPanel panel = new DocumentPanel(handler);
  panel.setElement(Document.get().<Element>cast());
  panel.addDomHandler(panel, KeyDownEvent.getType());
  panel.addDomHandler(panel, KeyPressEvent.getType());
  panel.addDomHandler(panel, KeyUpEvent.getType());
  RootPanel.detachOnWindowClose(panel);
  panel.onAttach();
}
项目:gwt-chronoscope    文件:ChartKeyPressHandler.java   
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();
  }
}
项目:easy-vote    文件:ElectionWidget.java   
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());
    }
}
项目:firefly    文件:PagingPanel.java   
/**
 * 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);
}
项目:gerrit    文件:SearchPanel.java   
@Override
protected void onLoad() {
  super.onLoad();
  if (regFocus == null) {
    regFocus =
        GlobalKey.addApplication(
            this,
            new KeyCommand(0, '/', Gerrit.C.keySearch()) {
              @Override
              public void onKeyPress(KeyPressEvent event) {
                event.preventDefault();
                searchBox.setFocus(true);
                searchBox.selectAll();
              }
            });
  }
}
项目:gerrit    文件:SideBySide.java   
@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();
}
项目:gerrit    文件:Header.java   
private KeyCommand setupNav(InlineHyperlink link, char key, String help, FileInfo info) {
  if (info != null) {
    final String url = url(info);
    link.setTargetHistoryToken(url);
    link.setTitle(
        PatchUtil.M.fileNameWithShortcutKey(
            FileInfo.getFileName(info.path()), Character.toString(key)));
    KeyCommand k =
        new KeyCommand(0, key, help) {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            Gerrit.display(url);
          }
        };
    keys.add(k);
    if (link == prev) {
      hasPrev = true;
    } else {
      hasNext = true;
    }
    return k;
  }
  link.getElement().getStyle().setVisibility(Visibility.HIDDEN);
  keys.add(new UpToChangeCommand(projectKey, patchSetId, 0, key));
  return null;
}
项目:platypus-js    文件:EventsExecutor.java   
public void setKeyTyped(JavaScriptObject aValue) {
    if (keyTyped != aValue) {
        if (keyTypedReg != null) {
            keyTypedReg.removeHandler();
            keyTypedReg = null;
        }
        keyTyped = aValue;
        if (keyTyped != null && component instanceof HasKeyPressHandlers) {
            keyTypedReg = ((HasKeyPressHandlers) component).addKeyPressHandler(new KeyPressHandler() {
                @Override
                public void onKeyPress(KeyPressEvent event) {
                    if (keyTyped != null) {
                        event.stopPropagation();
                        executeEvent(keyTyped, EventsPublisher.publish(event));
                    }
                }
            });
        }
    }
}
项目:yaph    文件:LoginPresenter.java   
public void bind() {
    RootPanel.get("container").add(getView().asWidget());
    getView().asWidget().setVisible(false);
    view.getLoginButton().addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            login();
        }
    });

    KeyPressHandler handler = new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            // Si on appuie sur "Entrée"
            if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode())
                login();
        }
    };

    getView().getLoginKeyPress().addKeyPressHandler(handler);
    getView().getPasswdKeyPress().addKeyPressHandler(handler);
    getView().asWidget().setVisible(true);
}
项目:qafe-platform    文件:EventFactory.java   
public static KeyPressHandler createOnKeyPressListener(final EventListenerGVO ev, final List<InputVariableGVO> input) {
    return new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (ev.getParameterList() != null) {
                Iterator<ParameterGVO> itr = ev.getParameterList().iterator();
                while (itr.hasNext()) {
                    ParameterGVO parameter = itr.next();
                    if (parameter != null) {
                        if (KeyBoardHelper.isKeyInput(parameter.getName(), parameter.getValue(), Character.toString(event.getCharCode()))) {
                            CallbackHandler.createCallBack(event.getSource(), QAMLConstants.EVENT_ONKEYPRESS, ev, input);
                        }
                    }
                }
            }
        }
    };
}
项目:qafe-platform    文件:QPagingOptions.java   
/**
 * 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) {
            char charCode = event.getCharCode();
            if (charCode == KeyCodes.KEY_ENTER) {
                QPagingOptions.this.table.gotoPage(getPagingBoxValue(), false);
            } else if (!Character.isDigit(charCode) && (charCode != KeyCodes.KEY_TAB) && (charCode != KeyCodes.KEY_BACKSPACE) && (charCode != KeyCodes.KEY_DELETE) && (charCode != KeyCodes.KEY_ENTER) && (charCode != KeyCodes.KEY_HOME) && (charCode != KeyCodes.KEY_END) && (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP) && (charCode != KeyCodes.KEY_RIGHT) && (charCode != KeyCodes.KEY_DOWN)) {
                curPageBox.cancelKey();
            }
        }
    };

    // Add the handler
    curPageBox.addKeyPressHandler(handler);
}
项目:qafe-platform    文件:ActivityHelper.java   
private static KeyPressHandler createKeyPressHandler(final ComponentGVO componentGVO, final EventListenerGVO eventGVO, final NotifyHandler notifyHandler, final String windowId, final String context, final AbstractActivity activity) {
    return new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (eventGVO.getParameterList() == null) {
                return;
            }
            Iterator<ParameterGVO> itrParameter = eventGVO.getParameterList().iterator();
            while (itrParameter.hasNext()) {
                ParameterGVO parameterGVO = itrParameter.next();
                if (parameterGVO == null) {
                    continue;
                }
                if (KeyBoardHelper.isKeyInput(parameterGVO.getName(), parameterGVO.getValue(), Character.toString(event.getCharCode()))) {
                    UIObject widget = (UIObject)event.getSource();
                    List<InputVariableGVO> inputVariables = eventGVO.getInputvariablesList();
                    handleEvent(componentGVO, widget, eventGVO, event, QAMLConstants.EVENT_ONKEYPRESS, inputVariables, notifyHandler, windowId, context, activity);
                    break;
                }
            }
        }
    };
}
项目:putnami-web-toolkit    文件:AddressBookView.java   
@UiHandler("searchBox")
void onSearchBox(KeyPressEvent event) {
    final InputText source = (InputText) event.getSource();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            String query = source.flush();
            if (query == null || query.length() == 0) {
                displayList(displayedList);
            } else {
                final String queryToCompare = query.toLowerCase().trim();
                Iterable<Contact> filteredIteable = Iterables.filter(displayedList, new Predicate<Contact>() {

                    @Override
                    public boolean apply(Contact contact) {
                        return contact.getName() != null && contact.getName().toLowerCase().contains(queryToCompare);
                    }
                });
                displayList(Lists.newArrayList(filteredIteable));
            }
        }
    });
}
项目:putnami-web-toolkit    文件:MaskValueBoxHelper.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    int i = helpers.indexOf(currentHelper);
    if (currentHelper != null) {
        if (currentHelper.handleKeyPress(event)) {
            refreshValueBox();
            event.preventDefault();
        } else if (1 + i < helpers.size()) {
            if (!helpers.get(1 + i).handleKeyPress(event)
                && 2 + i < helpers.size()) {
                focus(i + 1);
                helpers.get(2 + i).handleKeyPress(event);
            } else {
                focus(i + 1);
            }
        } else {
            event.preventDefault();
        }
    }
}
项目:putnami-web-toolkit    文件:AddressBookPage.java   
@UiHandler("searchBox")
void onSearchBox(KeyPressEvent event) {
    final InputText source = (InputText) event.getSource();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            String query = source.flush();
            if (query == null || query.length() == 0) {
                AddressBookPage.this.displayList(AddressBookPage.this.displayedList);
            } else {
                final String queryToCompare = query.toLowerCase().trim();
                Iterable<Contact> filteredIteable =
                    Iterables.filter(AddressBookPage.this.displayedList, new Predicate<Contact>() {

                        @Override
                        public boolean apply(Contact contact) {
                            return contact.getName() != null
                                && contact.getName().toLowerCase().contains(queryToCompare);
                        }
                    });
                AddressBookPage.this.displayList(Lists.newArrayList(filteredIteable));
            }
        }
    });
}
项目:prima-aletheia-web-emop    文件:WebLayoutEditor.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    try {
        int code = event.getUnicodeCharCode(); 
        if (code == '\u002B')
            pageView.zoomIn();
        else if (code == '\u2212' || code == '\u2010' || code == '\u002D')
            pageView.zoomOut();
        else if (code == '\u2212' || code == '\u2010' || code == '\u002D')
            pageView.zoomOut();
        //else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_PAGEDOWN)
        //  selectNextObject();
        //else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_PAGEUP)
        //  selectPreviousObject();
        //else
        //  Window.alert(""+code);
    } catch (Exception exc) {
        logManager.logError(ERROR_UNSPECIFIED, "Error in onKeyPress()");
        exc.printStackTrace();
    }
}
项目:rva    文件:ColorPickerRGB.java   
/**
 * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the physical key that was pressed.
 *
 * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int).
 *
 * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that the Widget recieves its events.
 * @param sender the widget that was focused when the event occurred.
 * @see com.google.gwt.user.client.ui.KeyboardListener
 */
public void onKeyPress(KeyPressEvent event) {
    Widget sender = (Widget) event.getSource();
    char keyCode = event.getCharCode();

    // Disallow non-numerics in numeric boxes
    if ((!Character.isDigit(keyCode))
        && (keyCode != (char) KeyCodes.KEY_TAB)
        && (keyCode != (char) KeyCodes.KEY_BACKSPACE)
        && (keyCode != (char) KeyCodes.KEY_DELETE) && (keyCode != (char) KeyCodes.KEY_ENTER)
        && (keyCode != (char) KeyCodes.KEY_HOME) && (keyCode != (char) KeyCodes.KEY_END)
        && (keyCode != (char) KeyCodes.KEY_LEFT) && (keyCode != (char) KeyCodes.KEY_UP)
        && (keyCode != (char) KeyCodes.KEY_RIGHT) && (keyCode != (char) KeyCodes.KEY_DOWN))
    {
        ((TextBox)sender).cancelKey();
    }
}
项目:rva    文件:ColorPickerHSV.java   
/**
 * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the physical key that was pressed.
 *
 * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int).
 *
 * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that the Widget recieves its events.
 * @param sender the widget that was focused when the event occurred.
 * @see com.google.gwt.user.client.ui.KeyboardListener
 */
public void onKeyPress(KeyPressEvent event) {
    Widget sender = (Widget) event.getSource();
    char keyCode = event.getCharCode();

    // Disallow non-numerics in numeric boxes
    if ((!Character.isDigit(keyCode))
        && (keyCode != (char) KeyCodes.KEY_TAB)
        && (keyCode != (char) KeyCodes.KEY_BACKSPACE)
        && (keyCode != (char) KeyCodes.KEY_DELETE) && (keyCode != (char) KeyCodes.KEY_ENTER)
        && (keyCode != (char) KeyCodes.KEY_HOME) && (keyCode != (char) KeyCodes.KEY_END)
        && (keyCode != (char) KeyCodes.KEY_LEFT) && (keyCode != (char) KeyCodes.KEY_UP)
        && (keyCode != (char) KeyCodes.KEY_RIGHT) && (keyCode != (char) KeyCodes.KEY_DOWN))
    {
        ((TextBox)sender).cancelKey();
    }
}
项目:socom    文件:ReportPopup.java   
private void limitArea() {
    reportTextArea.getElement().setAttribute("maxlength", String.valueOf(MAX_REPORT_LENGTH));
    reportTextArea.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            int size = reportTextArea.getText().length();
            textLength.setText(String.valueOf(MAX_REPORT_LENGTH-size));

            if(size == MAX_REPORT_LENGTH) {
                Animation a = new Animation() {
                    @Override
                    protected void onUpdate(double progress) {
                        String rgbvalue = "rgb(" + ((int)((1-progress)*255)) + ",0,0)";
                        textLengthPanel.getElement().getStyle().setProperty("color", rgbvalue);
                    }
                };
                a.run(1000);
            }
        }
    });
}
项目:opennmszh    文件:Code.java   
@SuppressWarnings("rawtypes")
public Code(KeyEvent event){
    if (event != null){
        if (event instanceof KeyPressEvent){
            kP_Event = (KeyPressEvent)event;
        } else if (event instanceof KeyDownEvent){
            kD_Event = (KeyDownEvent)event;
        }
        isCtrlDown = event.isControlKeyDown();
        isAltDown = event.isAltKeyDown();
        isShiftDown  = event.isShiftKeyDown();
    }
    int temp = 0;
    if (kP_Event != null){
        charCode = kP_Event.getUnicodeCharCode();
    } else if (kD_Event != null){
        temp = keyCode = kD_Event.getNativeKeyCode();
    } 
    isFunctionKey = false;
    for (int k : keyCodes){
        if (temp == k) {
            isFunctionKey = true;
            break;
        }
    }
}
项目:gwtbootstrap3    文件:AbstractForm.java   
public void setSubmitOnEnter(boolean submitOnEnter) {
    if (submitOnEnter) {
        if (submitOnEnterRegistration == null)
            submitOnEnterRegistration = addDomHandler(new KeyPressHandler() {
                @Override
                public void onKeyPress(KeyPressEvent event) {
                    if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                        if (validate()) {
                            fireSubmitEvent();
                        }
                    }
                }
            }, KeyPressEvent.getType());
    } else if (submitOnEnterRegistration != null) {
        submitOnEnterRegistration.removeHandler();
        submitOnEnterRegistration = null;
    }
}
项目:incubator-wave    文件:FocusManager.java   
/**
 * Installs a key handler for key events on this window.
 *
 * @param handler handler to receive key events.
 */
static void install(KeySignalHandler handler) {
  //
  // NOTE: There are three potential candidate elements for sinking keyboard
  // events: the window, the document, and the document body. IE7 does not
  // fire events on the window element, and GWT's RootPanel is already a
  // listener on the body, leaving the document as the only cross-browser
  // whole-window event-sinking 'element'.
  //
  DocumentPanel panel = new DocumentPanel(handler);
  panel.setElement(Document.get().<Element>cast());
  panel.addDomHandler(panel, KeyDownEvent.getType());
  panel.addDomHandler(panel, KeyPressEvent.getType());
  panel.addDomHandler(panel, KeyUpEvent.getType());
  RootPanel.detachOnWindowClose(panel);
  panel.onAttach();
}
项目:obsolete-web-boards-gwt    文件:SVGZoomAndPanHandler.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    char c = event.getCharCode();
    switch (c) {
    case '[':case 'q':
        scale /= KEY_ZOOM_STEP;
        updateZoom();
        break;
    case ']':case 'w':
        scale *= KEY_ZOOM_STEP;
        updateZoom();
        break;
    case '\\': case '1':
        scale = 1;
        updateZoom();
        OMSVGRect viewBox = svg.getViewBox().getBaseVal();
        viewBox.setX(0);
        viewBox.setY(0);
        break;
    }
}
项目:unitimes    文件:NumberBox.java   
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( );
        }
    } );
}
项目:Wiab.pro    文件:ContactInputWidget.java   
@Override
public void onKeyPress(KeyPressEvent event) {
  if (listener != null) {
    if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
      listener.onSelect(getInput());
    } else {
      listener.onInput(getInput());
    }
  }
}
项目:x-cure-chat    文件:Transliterator.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    //Window.alert("Char code: '" + (int) getCharCode( event.getNativeEvent() ) + "', key code: " + event.getNativeEvent().getKeyCode());
    //Substitute characters if the transliteration is on and the text input is enabled
    if( textObject.isEnabled() ) {
        final Character charCode = getCharCode( event.getNativeEvent() );
        if( processNewCharacter( charCode ) ) {
            event.stopPropagation();
            event.preventDefault();
        }
    }
}
项目:x-cure-chat    文件:InfoPopupPanel.java   
protected InfoPopupPanel(boolean autoHide, boolean modal){
    super(autoHide, modal);

    //Register the popup in the list of popups eligible for closing on user-logout
    SiteManagerUI.getInstance().registerPopup( this );

    //Set Animation ON
    this.setAnimationEnabled( true );

    //Add the close by escape handler
    this.addDomHandler( new KeyPressHandler(){
        public void onKeyPress( KeyPressEvent event ){
            NativeEvent nativeEvent = event.getNativeEvent();
            if( ( nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE ) ) {
                hide();
            }
        }
    }, KeyPressEvent.getType() );

    //Set the width of the panel
    //this.setWidth("25%");

    //Adding decorator panel inside the pop-up because 
    //we want the panel to have rounded borders.
    decoratedPanel.setSize( "100%", "100%");
    decoratedPanel.setStyleName( CommonResourcesContainer.INFO_POPUP_STYLE_NAME );
    this.add( decoratedPanel );
}
项目:ontobrowser    文件:EditTermPopup.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    int keyCode = event.getCharCode();
    if(keyCode == KEY_ENTER) {
        submit();
    }
}
项目:ontobrowser    文件:AddSynonymPopup.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    int keyCode = event.getCharCode();
    if(keyCode == KEY_ENTER) {
        submit();
    }
}
项目:ontobrowser    文件:ChangePasswordPopup.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    int keyCode = event.getCharCode();
    if(keyCode == KEY_ENTER) {
        submit();
    }
}
项目:ontobrowser    文件:CreateChildTermPopup.java   
@Override
public void onKeyPress(KeyPressEvent event) {
    int keyCode = event.getCharCode();
    if(keyCode == KEY_ENTER) {
        submit();
    }
}
项目:listmaker    文件:PromptedTextArea.java   
@Override
public void onKeyPress(KeyPressEvent event)
{
    if (promptText.equals(this.getText())
            && !(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB))
    {
        hidePrompt();
    }
}
项目:listmaker    文件:PromptedTextBox.java   
@Override
public void onKeyPress(KeyPressEvent event)
{
    if (promptText.equals(this.getText())
        && !(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB))
    {
        hidePrompt();
    }
}
项目:che    文件:KeyboardNavigationHandler.java   
public void bind(Widget target) {
  if (component != null) {
    registration.removeHandler();
  }

  if (target != null) {
    if (keyEvent == Event.ONKEYDOWN) {
      registration = target.addDomHandler(handler, KeyDownEvent.getType());
    } else {
      registration = target.addDomHandler(handler, KeyPressEvent.getType());
    }
  }

  component = target;
}
项目:r01fb    文件:TreeView.java   
@Override
public HandlerRegistration addKeyPressHandler(final KeyPressHandler handler) {
    return this.addDomHandler(handler,
                              KeyPressEvent.getType());
}
项目:OpenTripPlanner-client-gwt    文件:ValueTextBox.java   
@Override
public void onKeyPress(KeyPressEvent event) {

    if (isReadOnly() || !isEnabled()) {
        return;
    }

    int keyCode = event.getNativeEvent().getKeyCode();

    switch (keyCode) {
    case KeyCodes.KEY_LEFT:
    case KeyCodes.KEY_RIGHT:
    case KeyCodes.KEY_BACKSPACE:
    case KeyCodes.KEY_DELETE:
    case KeyCodes.KEY_TAB:
    case KeyCodes.KEY_UP:
    case KeyCodes.KEY_DOWN:
        return;
    }

    int index = getCursorPos();
    String previousText = getText();
    String newText;
    if (getSelectionLength() > 0) {
        newText = previousText.substring(0, getCursorPos())
                + event.getCharCode()
                + previousText.substring(
                        getCursorPos() + getSelectionLength(),
                        previousText.length());
    } else {
        newText = previousText.substring(0, index) + event.getCharCode()
                + previousText.substring(index, previousText.length());
    }
    cancelKey();

    setValue(newText, true);
}
项目:firefly    文件:Form.java   
public void onKeyPress(KeyPressEvent ev) {
    if (submitButton == null) return;
    final int keyCode = ev.getNativeEvent().getKeyCode();
    char charCode = ev.getCharCode();
    if ((keyCode == KeyCodes.KEY_ENTER || charCode == KeyCodes.KEY_ENTER) && ev.getRelativeElement() != null) {
        DeferredCommand.addCommand(new SubmitCommand());
    }
}
项目:firefly    文件:PagingOptions.java   
/**
* 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) {
            char charCode = event.getCharCode();
            if (charCode == KeyCodes.KEY_ENTER) {
                PagingOptions.this.imageGridPanel.getImageGrid().gotoPage(getPagingBoxValue(), false);
            } else if (!Character.isDigit(charCode)
                    && (charCode != KeyCodes.KEY_TAB)
                    && (charCode != KeyCodes.KEY_BACKSPACE)
                    && (charCode != KeyCodes.KEY_DELETE)
                    && (charCode != KeyCodes.KEY_ENTER)
                    && (charCode != KeyCodes.KEY_HOME)
                    && (charCode != KeyCodes.KEY_END)
                    && (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP)
                    && (charCode != KeyCodes.KEY_RIGHT)
                    && (charCode != KeyCodes.KEY_DOWN)) {
                curPageBox.cancelKey();
            }
        }
    };

    // Add the handler
    curPageBox.addKeyPressHandler(handler);
}