Search in sources :

Example 46 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent 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

KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)46 Test (org.junit.Test)30 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)15 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)5 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 FindTextBox (org.rstudio.core.client.widget.FindTextBox)3 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)2 MouseDownHandler (com.google.gwt.event.dom.client.MouseDownHandler)2 EventHandler (com.google.gwt.event.shared.EventHandler)2 CanFocus (org.rstudio.core.client.widget.CanFocus)2 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)2 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)2 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)2 Transform (com.ait.lienzo.client.core.types.Transform)1