Java Code Examples for com.google.gwt.user.client.DOM#eventPreventDefault()
The following examples show how to use
com.google.gwt.user.client.DOM#eventPreventDefault() .
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: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Listener for popupopener. */ @Override public void onClick(ClickEvent event) { debug("VComboBoxMultiselect: onClick()"); if (this.enabled && !this.readonly) { getDataReceivedHandler().blurUpdate = false; // ask suggestionPopup if it was just closed, we are using GWT // Popup's auto close feature if (!this.suggestionPopup.isJustClosed()) { filterOptions(-1, ""); this.dataReceivedHandler.popupOpenerClicked(); } DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); focus(); setText(""); } }
Example 2
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
/** * Listener for popupopener. */ @Override public void onClick(ClickEvent event) { debug("VComboBoxMultiselect: onClick()"); if (this.enabled && !this.readonly) { getDataReceivedHandler().blurUpdate = false; // ask suggestionPopup if it was just closed, we are using GWT // Popup's auto close feature if (!this.suggestionPopup.isJustClosed()) { filterOptions(-1, ""); this.dataReceivedHandler.popupOpenerClicked(); } DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); focus(); setText(""); } }
Example 3
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if (this.enabled && !this.readonly) { int keyCode = event.getNativeKeyCode(); debug("VComboBoxMultiselect: key down: " + keyCode); if (this.dataReceivedHandler.isWaitingForFilteringResponse() && navigationKeyCodes.contains(keyCode) && (!this.allowNewItems || keyCode != KeyCodes.KEY_ENTER)) { /* * Keyboard navigation events should not be handled while we are * waiting for a response. This avoids flickering, disappearing * items, wrongly interpreted responses and more. */ debug("Ignoring " + keyCode + " because we are waiting for a filtering response"); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); return; } if (this.suggestionPopup.isAttached()) { debug("Keycode " + keyCode + " target is popup"); popupKeyDown(event); } else { debug("Keycode " + keyCode + " target is text field"); inputFieldKeyDown(event); } } }
Example 4
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if (this.enabled && !this.readonly) { int keyCode = event.getNativeKeyCode(); debug("VComboBoxMultiselect: key down: " + keyCode); if (this.dataReceivedHandler.isWaitingForFilteringResponse() && navigationKeyCodes.contains(keyCode) && (!this.allowNewItems || keyCode != KeyCodes.KEY_ENTER)) { /* * Keyboard navigation events should not be handled while we are * waiting for a response. This avoids flickering, disappearing * items, wrongly interpreted responses and more. */ debug("Ignoring " + keyCode + " because we are waiting for a filtering response"); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); return; } if (this.suggestionPopup.isAttached()) { debug("Keycode " + keyCode + " target is popup"); popupKeyDown(event); } else { debug("Keycode " + keyCode + " target is text field"); inputFieldKeyDown(event); } } }
Example 5
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 5 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disbles the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); Main.get().mainPanel.search.historySearch.searchSaved.getSearch(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); Main.get().mainPanel.search.historySearch.searchSaved.showMenu(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 6
Source File: ExtendedScrollTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { boolean headerFired = false; // Controls when event is fired by header // Case targe event is header must disable drag & drop if (headerTable.getEventTargetCell(event) != null) { headerFired = true; } // Selects the panel setSelectedPanel(true); // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disbles the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); if ((isDocumentSelected() || isAttachmentSelected()) && Main.get().workspaceUserProperties.getWorkspace().getAvailableOption().isDownloadOption()) { Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.downloadDocument(); } } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: if (!headerFired) { if (isDocumentSelected() || isAttachmentSelected()) { Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.menuPopup.menu.checkMenuOptionPermissions(getDocument()); } else if (isFolderSelected()) { Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.menuPopup.menu.checkMenuOptionPermissions(getFolder()); } else if (isMailSelected()) { Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.menuPopup.menu.checkMenuOptionPermissions(getMail()); } Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.menuPopup.menu.evaluateMenuOptions(); Main.get().mainPanel.search.searchBrowser.searchResult.searchCompactResult.showMenu(); DOM.eventPreventDefault(event); // Prevent to fire event to browser } break; default: break; } } super.onBrowserEvent(event); }
Example 7
Source File: SuggestionMenu.java From incubator-retired-wave with Apache License 2.0 | 4 votes |
private void handleEventInner(Event event) { switch (DOM.eventGetType(event)) { case Event.ONCONTEXTMENU: event.preventDefault(); break; case Event.ONKEYPRESS: case Event.ONKEYDOWN: { // NOTE(user): It is necessary to stop propagation on the key events to // prevent them from leaking to the blip/wave presenters. int keyCode = DOM.eventGetKeyCode(event); // Move left/right to previous/next drop down widget switch (keyCode) { case KeyCodes.KEY_LEFT: case KeyCodes.KEY_RIGHT: handler.handleLeftRight(keyCode == KeyCodes.KEY_RIGHT); event.stopPropagation(); return; case KeyCodes.KEY_ENTER: event.stopPropagation(); } if (keyCode >= '1' && keyCode <= '9') { // TODO(danilatos): Is this ok? i18n etc? int index = keyCode - '1'; if (index >= 0 && index < getItems().size()) { MenuItem item = getItems().get(index); if (item == null) { return; } item.getCommand().execute(); DOM.eventPreventDefault(event); } } break; } case Event.ONMOUSEOUT: { // Need to check that we really seem to have left the menu, as // mouse-out events get triggered whenever the mouse moves between // selections in the menu. EventTarget target = event.getRelatedEventTarget(); Element targetElement = Element.as(target); if (!getElement().isOrHasChild(targetElement)) { handler.handleMouseOut(); } break; } case Event.ONMOUSEOVER: { handler.handleMouseOver(); break; } } }
Example 8
Source File: SuggestionMenu.java From swellrt with Apache License 2.0 | 4 votes |
private void handleEventInner(Event event) { switch (DOM.eventGetType(event)) { case Event.ONCONTEXTMENU: event.preventDefault(); break; case Event.ONKEYPRESS: case Event.ONKEYDOWN: { // NOTE(user): It is necessary to stop propagation on the key events to // prevent them from leaking to the blip/wave presenters. int keyCode = DOM.eventGetKeyCode(event); // Move left/right to previous/next drop down widget switch (keyCode) { case KeyCodes.KEY_LEFT: case KeyCodes.KEY_RIGHT: handler.handleLeftRight(keyCode == KeyCodes.KEY_RIGHT); event.stopPropagation(); return; case KeyCodes.KEY_ENTER: event.stopPropagation(); } if (keyCode >= '1' && keyCode <= '9') { // TODO(danilatos): Is this ok? i18n etc? int index = keyCode - '1'; if (index >= 0 && index < getItems().size()) { MenuItem item = getItems().get(index); if (item == null) { return; } item.getCommand().execute(); DOM.eventPreventDefault(event); } } break; } case Event.ONMOUSEOUT: { // Need to check that we really seem to have left the menu, as // mouse-out events get triggered whenever the mouse moves between // selections in the menu. EventTarget target = event.getRelatedEventTarget(); Element targetElement = Element.as(target); if (!getElement().isOrHasChild(targetElement)) { handler.handleMouseOut(); } break; } case Event.ONMOUSEOVER: { handler.handleMouseOver(); break; } } }
Example 9
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
/** * Triggered when a key was pressed in the suggestion popup. * * @param event * The KeyDownEvent of the key */ private void popupKeyDown(KeyDownEvent event) { debug("VComboBoxMultiselect: popupKeyDown(" + event.getNativeKeyCode() + ")"); // Propagation of handled events is stopped so other handlers such as // shortcut key handlers do not also handle the same events. switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: this.suggestionPopup.selectNextItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_UP: this.suggestionPopup.selectPrevItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_PAGEDOWN: selectNextPage(); event.stopPropagation(); break; case KeyCodes.KEY_PAGEUP: selectPrevPage(); event.stopPropagation(); break; case KeyCodes.KEY_ESCAPE: reset(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ENTER: // queue this, may be cancelled by selection int selectedIndex = this.suggestionPopup.menu.getSelectedIndex(); if (!this.allowNewItems && selectedIndex != -1) { debug("index before: " + selectedIndex); if (this.showClearButton) { selectedIndex = selectedIndex - 1; } if (this.showSelectAllButton) { selectedIndex = selectedIndex - 1; } debug("index after: " + selectedIndex); if (selectedIndex == -2) { this.clearCmd.execute(); } else if (selectedIndex == -1) { if (this.showSelectAllButton) { this.selectAllCmd.execute(); } else { this.clearCmd.execute(); } } debug("entered suggestion: " + this.currentSuggestions.get(selectedIndex).caption); onSuggestionSelected(this.currentSuggestions.get(selectedIndex)); } else { this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText()); } event.stopPropagation(); break; } }
Example 10
Source File: ExtendedTree.java From document-management-system with GNU General Public License v2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { // When de button mouse is released if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // remove dragable item Main.get().draggable.clear(); switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: DOM.eventPreventDefault(event); // Prevent to fire event to browser flagPopup = true; mouseDownX = 0; mouseDownY = 0; dragged = false; Main.get().activeFolderTree.menuPopup.disableAllOptions(); fireSelection(elementClicked(DOM.eventGetTarget(event))); break; default: flagPopup = false; // dragging is enable only if cursor is inside actual item dragged = isCursorInsideActualItem(elementClicked(DOM.eventGetTarget(event))); mouseDownX = event.getScreenX(); mouseDownY = event.getClientY(); } } else if (DOM.eventGetType(event) == Event.ONMOUSEMOVE) { mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); if (Main.get().activeFolderTree.canDrag() && dragged && mouseDownX > 0 && mouseDownY > 0 && evalDragPixelSensibility()) { TreeItem actualItem = Main.get().activeFolderTree.getActualItem(); Main.get().draggable.show(actualItem.getHTML(), OriginPanel.TREE_ROOT); Main.get().activeFolderTree.fileBrowserRefreshDone(); mouseDownX = 0; mouseDownY = 0; dragged = false; } } else if (DOM.eventGetType(event) == Event.ONMOUSEUP || DOM.eventGetType(event) == Event.ONCLICK || DOM.eventGetType(event) == Event.ONDBLCLICK) { mouseDownX = 0; mouseDownY = 0; dragged = false; // Always disabling the popup flag } // Prevent folder creation or renaming propagate actions to other tree nodes int action = Main.get().activeFolderTree.getFolderAction(); if (action != FolderTree.ACTION_CREATE && action != FolderTree.ACTION_RENAME) { super.onBrowserEvent(event); } }
Example 11
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disbles the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); Main.get().mainPanel.search.historySearch.userNews.getSearch(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); Main.get().mainPanel.search.historySearch.userNews.showMenu(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 12
Source File: DragSourceSupport.java From appinventor-extensions with Apache License 2.0 | 4 votes |
public void eventPreventDefaultOfCurrentEvent() { DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); }
Example 13
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disables the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.refreshProposedSubscriptions(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.menuPopup.setPopupPosition(mouseX, mouseY); MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.menuPopup.show(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 14
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disables the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.refreshProposedQueries(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.setPopupPosition(mouseX, mouseY); MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.show(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 15
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disables the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.refreshMessagesSent(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.menuPopup.setPopupPosition(mouseX, mouseY); MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.menuPopup.show(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 16
Source File: ExtendedFlexTable.java From document-management-system with GNU General Public License v2.0 | 4 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); } // Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action if (selectedRow >= 0) { // When de button mouse is released mouseX = DOM.eventGetClientX(event); mouseY = DOM.eventGetClientY(event); // On double click not sends event to onCellClicked across super.onBrowserEvent(); if (DOM.eventGetType(event) == Event.ONDBLCLICK) { // Disables the event propagation the sequence is: // Two time entry onCellClicked before entry on onBrowserEvent and disables the // Tree onCellClicked that produces inconsistence error refreshing DOM.eventCancelBubble(event, true); MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.refreshMessagesReceived(); } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { switch (DOM.eventGetButton(event)) { case Event.BUTTON_RIGHT: markSelectedRow(selectedRow); MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.menuPopup.setPopupPosition(mouseX, mouseY); MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.menuPopup.show(); DOM.eventPreventDefault(event); // Prevent to fire event to browser break; default: break; } } } super.onBrowserEvent(event); }
Example 17
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
/** * Triggered when a key was pressed in the suggestion popup. * * @param event * The KeyDownEvent of the key */ private void popupKeyDown(KeyDownEvent event) { debug("VComboBoxMultiselect: popupKeyDown(" + event.getNativeKeyCode() + ")"); // Propagation of handled events is stopped so other handlers such as // shortcut key handlers do not also handle the same events. switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: this.suggestionPopup.selectNextItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_UP: this.suggestionPopup.selectPrevItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_PAGEDOWN: selectNextPage(); event.stopPropagation(); break; case KeyCodes.KEY_PAGEUP: selectPrevPage(); event.stopPropagation(); break; case KeyCodes.KEY_ESCAPE: reset(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ENTER: // queue this, may be cancelled by selection int selectedIndex = this.suggestionPopup.menu.getSelectedIndex(); if (!this.allowNewItems && selectedIndex != -1) { debug("index before: " + selectedIndex); if (this.showClearButton) { selectedIndex = selectedIndex - 1; } if (this.showSelectAllButton) { selectedIndex = selectedIndex - 1; } debug("index after: " + selectedIndex); if (selectedIndex == -2) { this.clearCmd.execute(); } else if (selectedIndex == -1) { if (this.showSelectAllButton) { this.selectAllCmd.execute(); } else { this.clearCmd.execute(); } } debug("entered suggestion: " + this.currentSuggestions.get(selectedIndex).caption); onSuggestionSelected(this.currentSuggestions.get(selectedIndex)); } else { this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText()); } event.stopPropagation(); break; } }
Example 18
Source File: MockComponent.java From appinventor-extensions with Apache License 2.0 | 4 votes |
private static void cancelBrowserEvent(Event event) { DOM.eventPreventDefault(event); DOM.eventCancelBubble(event, true); }