Search in sources :

Example 6 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class ProjectTagsScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    initPageHeader();
    prev = PagingHyperlink.createPrev();
    prev.setVisible(false);
    next = PagingHyperlink.createNext();
    next.setVisible(false);
    addPanel = new FlowPanel();
    Grid addGrid = new Grid(2, 2);
    addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
    int texBoxLength = 50;
    nameTxtBox = new HintTextBox();
    nameTxtBox.setVisibleLength(texBoxLength);
    nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
    nameTxtBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":");
    addGrid.setWidget(0, 1, nameTxtBox);
    irevTxtBox = new HintTextBox();
    irevTxtBox.setVisibleLength(texBoxLength);
    irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
    irevTxtBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(1, 0, AdminConstants.I.initialRevision() + ":");
    addGrid.setWidget(1, 1, irevTxtBox);
    addTag = new Button(AdminConstants.I.buttonAddTag());
    addTag.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            doAddNewTag();
        }
    });
    addPanel.add(addGrid);
    addPanel.add(addTag);
    tagTable = new TagsTable();
    delTag = new Button(AdminConstants.I.buttonDeleteTag());
    delTag.setStyleName(Gerrit.RESOURCES.css().branchTableDeleteButton());
    delTag.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tagTable.deleteChecked();
        }
    });
    HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().branchTablePrevNextLinks());
    buttons.add(delTag);
    buttons.add(prev);
    buttons.add(next);
    add(tagTable);
    add(buttons);
    add(addPanel);
}
Also used : HintTextBox(com.google.gerrit.client.ui.HintTextBox) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Button(com.google.gwt.user.client.ui.Button) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 7 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class GlobalKey method initEvents.

private static void initEvents() {
    if (active == null) {
        DocWidget.get().addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                final KeyCommandSet s = active.live;
                if (s != active.all) {
                    active.live = active.all;
                    restoreTimer.cancel();
                }
                s.onKeyPress(event);
            }
        });
        restoreTimer = new Timer() {

            @Override
            public void run() {
                active.live = active.all;
            }
        };
        global = new State(null);
        active = global;
    }
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Timer(com.google.gwt.user.client.Timer)

Example 8 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project rstudio by rstudio.

the class DomUtils method addKeyHandlers.

public static void addKeyHandlers(HasAllKeyHandlers widget, final NativeEventHandler handler) {
    widget.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(final KeyDownEvent event) {
            handler.onNativeEvent(event.getNativeEvent());
        }
    });
    widget.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(final KeyPressEvent event) {
            handler.onNativeEvent(event.getNativeEvent());
        }
    });
    widget.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(final KeyUpEvent event) {
            handler.onNativeEvent(event.getNativeEvent());
        }
    });
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)

Example 9 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project rstudio by rstudio.

the class ChooseFolderDialog method createMainWidget.

@Override
public Widget createMainWidget() {
    Widget mainWidget = super.createMainWidget();
    browser_.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            maybeInvalidateSelection();
        }
    });
    browser_.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            maybeInvalidateSelection();
        }
    });
    return mainWidget;
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) Widget(com.google.gwt.user.client.ui.Widget) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)

Example 10 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project perun by CESNET.

the class SuggestBox method addEventsToTextBox.

private void addEventsToTextBox() {
    class TextBoxEvents extends HandlesAllKeyEvents implements ValueChangeHandler<String> {

        public void onKeyDown(KeyDownEvent event) {
            switch(event.getNativeKeyCode()) {
                case KeyCodes.KEY_DOWN:
                    display.moveSelectionDown();
                    break;
                case KeyCodes.KEY_UP:
                    display.moveSelectionUp();
                    break;
                case KeyCodes.KEY_ENTER:
                case KeyCodes.KEY_TAB:
                    Suggestion suggestion = display.getCurrentSelection();
                    if (suggestion == null) {
                        display.hideSuggestions();
                    } else {
                        setNewSelection(suggestion);
                    }
                    break;
            }
            delegateEvent(SuggestBox.this, event);
        }

        public void onKeyPress(KeyPressEvent event) {
            delegateEvent(SuggestBox.this, event);
        }

        public void onKeyUp(KeyUpEvent event) {
            // After every user key input, refresh the popup's suggestions.
            refreshSuggestions();
            delegateEvent(SuggestBox.this, event);
        }

        public void onValueChange(ValueChangeEvent<String> event) {
            delegateEvent(SuggestBox.this, event);
        }
    }
    TextBoxEvents events = new TextBoxEvents();
    events.addKeyHandlersTo(box);
    box.addValueChangeHandler(events);
}
Also used : Suggestion(com.google.gwt.user.client.ui.SuggestOracle.Suggestion) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) HandlesAllKeyEvents(com.google.gwt.event.dom.client.HandlesAllKeyEvents) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)

Aggregations

KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)19 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)11 KeyCommand (com.google.gwtexpui.globalkey.client.KeyCommand)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Button (com.google.gwt.user.client.ui.Button)4 HintTextBox (com.google.gerrit.client.ui.HintTextBox)3 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 KeyCommandSet (com.google.gwtexpui.globalkey.client.KeyCommandSet)3 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 Event (com.google.gwt.user.client.Event)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Grid (com.google.gwt.user.client.ui.Grid)2 TextBox (com.google.gwt.user.client.ui.TextBox)2 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)2