com.google.gwt.event.dom.client.KeyUpEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.KeyUpEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FocusManager.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #2
Source File: AriaStatus.java    From unitime with Apache License 2.0 6 votes vote down vote up
public static AriaStatus getInstance() {
	if (sStatus == null) {
		RootPanel statusPanel = RootPanel.get("UniTimeGWT:AriaStatus");
		if (statusPanel != null && "1".equals(Window.Location.getParameter("aria"))) {
			sStatus = new AriaStatus(statusPanel.getElement(), false);
			sStatus.setStyleName("unitime-VisibleAriaStatus");
		} else {
			sStatus  = new AriaStatus(false);
			RootPanel.get().add(sStatus);
		}
		
		RootPanel.get().addDomHandler(new KeyUpHandler() {
			@Override
			public void onKeyUp(KeyUpEvent event) {
   				if (event.getNativeEvent().getKeyCode() == 191 && (event.isControlKeyDown() || event.isAltKeyDown())) {
   					sStatus.setHTML(sStatus.getHTML());
   				}
   			}
   		}, KeyUpEvent.getType());
	}
	return sStatus;
}
 
Example #3
Source File: ToggleTool.java    From geowe-core with GNU General Public License v3.0 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 #4
Source File: ToggleTool.java    From geowe-core with GNU General Public License v3.0 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
Source File: AutoCompleteTextFieldConnector.java    From hawkbit with Eclipse Public License 1.0 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 #6
Source File: AutoCompleteTextFieldConnector.java    From hawkbit with Eclipse Public License 1.0 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 #7
Source File: ToggleTool.java    From geowe-core with GNU General Public License v3.0 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 #8
Source File: DataProviderFilter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Widget asWidget() {


        filter.setMaxLength(30);
        filter.setVisibleLength(20);
        filter.getElement().setAttribute("style", "width:120px;");

        filter.addKeyUpHandler(new KeyUpHandler() {
            @Override
            public void onKeyUp(KeyUpEvent keyUpEvent) {

                Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                    @Override
                    public void execute() {
                        String prefix = filter.getText();

                        if (prefix != null && !prefix.equals("")) {
                            // filter by prefix
                            filterByPrefix(prefix);
                        } else {
                            clearFilter();
                        }
                    }

                });
            }
        });
        HorizontalPanel panel = new HorizontalPanel();
        Label label = new Label(Console.CONSTANTS.common_label_filter() + ": ");
        panel.add(label);
        panel.add(filter);

        label.getElement().setAttribute("style", "padding-top:8px;margin-right:8px");
        return panel;
    }
 
Example #9
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Add key handler to diagram canvas.
 *  
 * @param panel
 */
protected  void addKeyHandler(DiagramCanvas panel){
	panel.addDomHandler(new KeyUpHandler() {
		@Override
		public void onKeyUp(KeyUpEvent event) {
			DiagramController.this.onKeyUp(event);
		}
	}, KeyUpEvent.getType());
}
 
Example #10
Source File: FocusManager.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #11
Source File: AbstractInputBox.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
	boolean fireDirty = false;
	if (AbstractInputBox.this.currentStringValue == null) {
		fireDirty = !Strings.isNullOrEmpty(AbstractInputBox.this.input.getText());
	} else {
		fireDirty = !AbstractInputBox.this.currentStringValue.equals(AbstractInputBox.this.input.getText());
	}
	if (fireDirty) {
		DirtyEvent.fire(AbstractInputBox.this);
	}
}
 
Example #12
Source File: ApplicationRootView.java    From bitcoin-transaction-explorer with MIT License 5 votes vote down vote up
@UiHandler("lookupField")
public void onLookupKeyUp(final KeyUpEvent event) {
  if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) {
    return;
  }

  final ApplicationPlace place = PlaceTokenParseUtil.parseToken(lookupField.getText());
  if (place == null) {
    // Do something, like show a mild error.
    return;
  }

  placeController.goTo(place);
}
 
Example #13
Source File: CourseFinderCourses.java    From unitime with Apache License 2.0 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 && isEnabled()) {
		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 && isEnabled()) {
		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 #14
Source File: CourseFinderMultipleCourses.java    From unitime with Apache License 2.0 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 && isEnabled()) {
		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 && isEnabled()) {
		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 #15
Source File: ZoomInTool.java    From geowe-core with GNU General Public License v3.0 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;
}
 
Example #16
Source File: ZoomOutTool.java    From geowe-core with GNU General Public License v3.0 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 #17
Source File: UtilComunicator.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * isSearchableKey
 *
 * @param event
 * @return
 */
public static boolean isSearchableKey(KeyUpEvent event) {
	if (event != null) {
		return Util.isSearchableKey(event);
	} else {
		return true;
	}
}
 
Example #18
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger action when key up event fired
 * 
 * @param event
 */
protected  void onKeyUp(KeyUpEvent event){
	logger.info("key" +event.getNativeKeyCode() );
	if(event.getNativeKeyCode()== 46){
		logger.info("delete widget");
		deleteWidget();
	}
}
 
Example #19
Source File: InputTemplateUrlWizard.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new YoungAndroid project wizard.
 */
public InputTemplateUrlWizard(final NewUrlDialogCallback callback) {
  super(MESSAGES.inputNewUrlCaption(), true, true);

  // Initialize the UI.
  setStylePrimaryName("ode-DialogBox");
  HorizontalPanel panel = new HorizontalPanel();

  urlTextBox = new LabeledTextBox(MESSAGES.newUrlLabel());
  urlTextBox.getTextBox().setWidth("250px");
  urlTextBox.getTextBox().addKeyUpHandler(new KeyUpHandler() {
    @Override
    public void onKeyUp(KeyUpEvent event) {
      int keyCode = event.getNativeKeyCode();
      if (keyCode == KeyCodes.KEY_ENTER) {
        handleOkClick();
      } else if (keyCode == KeyCodes.KEY_ESCAPE) {
        handleCancelClick();
      }
    }
  });

  VerticalPanel page = new VerticalPanel();
  panel.add(urlTextBox);
  page.add(panel);
  addPage(page);

  // Create finish command (create a new Young Android project).
  initFinishCommand(new Command() {
    @Override
    public void execute() {
      String hostUrl = urlTextBox.getText();
      if (TemplateUploadWizard.hasUrl(hostUrl)) {
        Window.alert("The Url " + hostUrl + " already exists.");
      } else {
        callback.updateTemplateOptions(hostUrl);
      }
    }
  });
}
 
Example #20
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Triggered when a key was depressed.
 *
 * @param event
 *            The KeyUpEvent of the key depressed
 */
@Override
public void onKeyUp(KeyUpEvent event) {
	debug("VComboBoxMultiselect: onKeyUp(" + event.getNativeKeyCode() + ")");

	if (this.enabled && !this.readonly) {
		switch (event.getNativeKeyCode()) {
		case KeyCodes.KEY_ENTER:
		case KeyCodes.KEY_TAB:
		case KeyCodes.KEY_SHIFT:
		case KeyCodes.KEY_CTRL:
		case KeyCodes.KEY_ALT:
		case KeyCodes.KEY_DOWN:
		case KeyCodes.KEY_UP:
		case KeyCodes.KEY_PAGEDOWN:
		case KeyCodes.KEY_PAGEUP:
		case KeyCodes.KEY_ESCAPE:
			// NOP
			break;
		default:
			if (this.textInputEnabled) {
				// when filtering, we always want to see the results on the
				// first page first.
				filterOptions(0);
			}
			break;
		}
	}
}
 
Example #21
Source File: FileTextBox.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * File textBox
 */
public FileTextBox() {
	textBox = new TextBox();
	textBox.addKeyUpHandler(new KeyUpHandler() {
		@Override
		public void onKeyUp(KeyUpEvent event) {
			switch (event.getNativeKeyCode()) {
				case (char) KeyCodes.KEY_ENTER:
					switch (action) {
						case ACTION_RENAME:
							if (textBox.getText().length() > 0) {
								Main.get().mainPanel.desktop.browser.fileBrowser.rename(textBox.getText());
							} else {
								Main.get().mainPanel.desktop.browser.fileBrowser.hideRename();
							}
							break;
					}
					Main.get().mainPanel.enableKeyShorcuts(); // Enables general keys applications
					break;

				case (char) KeyCodes.KEY_ESCAPE:
					switch (action) {
						case ACTION_RENAME:
							Main.get().mainPanel.desktop.browser.fileBrowser.hideRename();
							break;
					}
					Main.get().mainPanel.enableKeyShorcuts(); // Enables general keys applications
					break;
			}
		}
	});
	textBox.setVisibleLength(20);
	textBox.setStyleName("okm-FileBrowser-TextBox");
	initWidget(textBox);
}
 
Example #22
Source File: CubaSearchSelectWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
    if (enabled && !readonly) {
        switch (event.getNativeKeyCode()) {
            case KeyCodes.KEY_ENTER:
                String tbText = tb.getText() == null ? ""
                        : tb.getText();
                String currentText = currentSuggestion == null ? ""
                        : currentSuggestion.getReplacementString();
                if (!this.preventFilterAfterSelect && !tbText.equals(currentText)) {
                    filterOptions(currentPage);
                } else {
                    if (!event.isAnyModifierKeyDown()) {
                        event.stopPropagation();
                    }
                }
                this.preventFilterAfterSelect = false;
                break;
            case KeyCodes.KEY_TAB:
            case KeyCodes.KEY_SHIFT:
            case KeyCodes.KEY_CTRL:
            case KeyCodes.KEY_ALT:
            case KeyCodes.KEY_DOWN:
            case KeyCodes.KEY_UP:
            case KeyCodes.KEY_PAGEDOWN:
            case KeyCodes.KEY_PAGEUP:
                // NOP
                break;
            case KeyCodes.KEY_ESCAPE:
                reset();
                break;
        }
        updateEditState();
    }
}
 
Example #23
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Triggered when a key was depressed.
 *
 * @param event
 *            The KeyUpEvent of the key depressed
 */
@Override
public void onKeyUp(KeyUpEvent event) {
	debug("VComboBoxMultiselect: onKeyUp(" + event.getNativeKeyCode() + ")");

	if (this.enabled && !this.readonly) {
		switch (event.getNativeKeyCode()) {
		case KeyCodes.KEY_ENTER:
		case KeyCodes.KEY_TAB:
		case KeyCodes.KEY_SHIFT:
		case KeyCodes.KEY_CTRL:
		case KeyCodes.KEY_ALT:
		case KeyCodes.KEY_DOWN:
		case KeyCodes.KEY_UP:
		case KeyCodes.KEY_PAGEDOWN:
		case KeyCodes.KEY_PAGEUP:
		case KeyCodes.KEY_ESCAPE:
			// NOP
			break;
		default:
			if (this.textInputEnabled) {
				// when filtering, we always want to see the results on the
				// first page first.
				filterOptions(0);
			}
			break;
		}
	}
}
 
Example #24
Source File: FocusManager.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
  dispatch(event);
}
 
Example #25
Source File: ToggleTool.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public void setCancelable() {
	RootPanel.get().addDomHandler(setEscapeHandler(), KeyUpEvent.getType());
}
 
Example #26
Source File: FocusManager.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
  dispatch(event);
}
 
Example #27
Source File: HandlerPanel.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
  return addDomHandler(handler, KeyUpEvent.getType());
}
 
Example #28
Source File: CodeInputImpl.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
	this.fireLiveValueChangeEvent();
}
 
Example #29
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
	return this.addDomHandler(handler, KeyUpEvent.getType());
}
 
Example #30
Source File: MaskValueBoxHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onKeyUp(KeyUpEvent event) {
	if (this.currentHelper != null) {
		this.currentHelper.cancel();
	}
}