当前位置: 首页>>代码示例>>Java>>正文


Java KeyDownEvent.preventDefault方法代码示例

本文整理汇总了Java中com.google.gwt.event.dom.client.KeyDownEvent.preventDefault方法的典型用法代码示例。如果您正苦于以下问题:Java KeyDownEvent.preventDefault方法的具体用法?Java KeyDownEvent.preventDefault怎么用?Java KeyDownEvent.preventDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.event.dom.client.KeyDownEvent的用法示例。


在下文中一共展示了KeyDownEvent.preventDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent keyDownEvent) {

    if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {

        SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class);

        if (panel != null) {
            WidgetUtil.focus(panel.getParent().getElement());

            // prevent further bubbling of the event as it has only
            // navigational purpose if thrown at this depth. A subsequent
            // press of ESC is not stopped, so ESC abort actions of the
            // application should work as soon as the focus is in
            // "navigational mode" on a grid-cell
            keyDownEvent.preventDefault();
            keyDownEvent.stopPropagation();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:EscKeyDownHandler.java

示例2: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent event) {
	int key = event.getNativeKeyCode();
	if (event.isControlKeyDown()) {
		if (key == KEY_PLUS || key == KEY_MINUS) {
			app.getToolbar().zoomChangeClicked(key == KEY_PLUS ? 1 : -1);
			event.preventDefault();
		}
	} else if (!event.isShiftKeyDown()) {
		boolean handled = true;
		switch (key) {
		case KeyCodes.KEY_HOME:
			changePage(0, -1, -1);
			break;
		case KeyCodes.KEY_END:
			changePage(dataStore.getPageCount() - 1, 1, 1);
			break;
		default:
			handled = false;
		}
		if (handled)
			event.preventDefault();
	}
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:25,代码来源:SinglePageLayout.java

示例3: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown(final KeyDownEvent event) {
    final GridWidget selectedGridWidget = getSelectedGridWidget();
    if (selectedGridWidget == null) {
        return;
    }

    final KeyboardOperation operation = getOperation(event);
    if (operation == null) {
        return;
    }

    final boolean redraw = operation.perform(selectedGridWidget,
                                             event.isShiftKeyDown(),
                                             event.isControlKeyDown());

    event.preventDefault();
    event.stopPropagation();

    flushDOMElements(selectedGridWidget);

    if (redraw) {
        gridLayer.draw();
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:BaseGridWidgetKeyboardHandler.java

示例4: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown(final KeyDownEvent e) {
    final int keyCode = e.getNativeKeyCode();
    final boolean isShiftKeyDown = e.isShiftKeyDown();
    switch (keyCode) {
        case KeyCodes.KEY_TAB:
        case KeyCodes.KEY_ENTER:
            gridCell.flush();
            moveSelection(keyCode,
                          isShiftKeyDown);
            e.preventDefault();

        case KeyCodes.KEY_ESCAPE:
            gridCell.destroyResources();
            gridPanel.setFocus(true);
            gridLayer.batch();
    }

    e.stopPropagation();
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:21,代码来源:KeyDownHandlerCommon.java

示例5: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
public void onKeyDown(KeyDownEvent event) {
  ChartState chartInfo = getChartState(event);
  Chart chart = chartInfo.chart;
  boolean handled = true;
  int keyCode = event.getNativeKeyCode();
  // all checks (except TAB) are to prevent focus stealing by the browser.
    if (keyCode == KeyCodes.KEY_PAGEUP) {
    } else if (keyCode == KeyCodes.KEY_PAGEDOWN) {
    } else if (keyCode == KeyCodes.KEY_UP) {
        if (UP_NUM < KEY_DOWN_MAX) {
            if (UP_NUM != 0) {
                chart.nextZoom();
            }
            UP_NUM++;
        }
    } else if (keyCode == KeyCodes.KEY_DOWN) {
        if (DOWN_NUM < KEY_DOWN_MAX) {
            if (DOWN_NUM != 0) {
                chart.prevZoom();
            }
            DOWN_NUM++;
        }
    } else if (keyCode == KeyCodes.KEY_TAB) {
        handled = handleTabKey((Event) event.getNativeEvent(), chartInfo, keyCode,
                event.isShiftKeyDown());
    } else {
        handled = false;
    }
  chartInfo.setHandled(handled);
  if (handled) {
     event.stopPropagation();
     event.preventDefault();
  }
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:35,代码来源:ChartKeyDownHandler.java

示例6: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@UiHandler("editArea")
void onKeyDown(KeyDownEvent e) {
  resizeTimer.cancel();
  if ((e.isControlKeyDown() || e.isMetaKeyDown()) && !e.isAltKeyDown() && !e.isShiftKeyDown()) {
    switch (e.getNativeKeyCode()) {
      case 's':
      case 'S':
        e.preventDefault();
        CallbackGroup group = new CallbackGroup();
        save(group);
        group.done();
        return;
    }
  } else if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE && !isDirty()) {
    if (isNew()) {
      removeUI();
      restoreSelection();
      return;
    }
    setEdit(false);
    if (autoClosed) {
      setOpen(false);
    }
    getCm().focus();
    return;
  }
  expandTimer.schedule(250);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:DraftBox.java

示例7: onKeyDownInput

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@UiHandler("input")
void onKeyDownInput(KeyDownEvent e) {
  if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
    onCancel(null);
  } else if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
    e.stopPropagation();
    e.preventDefault();
    onSave(null);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:Topic.java

示例8: getEnterDomHandler

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
protected KeyDownHandler getEnterDomHandler() {
    return new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (handleDefaultAction()) {
                    event.preventDefault();
                    event.stopPropagation();
                }
            }
        }
    };
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:14,代码来源:BaseModal.java

示例9: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown( KeyDownEvent event )
{
	if( event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE )
	{
		if( edition == null )
			return;

		event.stopPropagation();
		event.preventDefault();

		killCurrentEdit();
	}
	else if( event.getNativeKeyCode() == KeyCodes.KEY_TAB )
	{
		if( edition == null )
			return;

		event.stopPropagation();
		event.preventDefault();

		// find next cell to be edited

		int editionRow = getRow( refMng.getRef( edition.editedObject ) );
		CellPos pos = null;
		if( event.isShiftKeyDown() )
			pos = getPrevPos( editionRow, edition.editedCol );
		else
			pos = getNextPos( editionRow, edition.editedCol );

		if( pos != null )
		{
			beginEdit( pos.row, pos.col );
			return;
		}
	}
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:38,代码来源:DynArrayInFlexTable.java

示例10: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
public void onKeyDown(KeyDownEvent event) {
    int keycode = event.getNativeKeyCode();
    // Catch tab and move between select:s
    if (keycode == KeyCodes.KEY_TAB && event.getSource() == options
            && !event.isShiftKeyDown()) {
        // Prevent default behavior
        event.preventDefault();
        // Remove current selections
        clearSelections(options, true);
        // Focus selections
        selections.setFocus(true);
    }

    if (keycode == KeyCodes.KEY_TAB && event.isShiftKeyDown()
            && event.getSource() == selections) {
        // Prevent default behavior
        event.preventDefault();
        // Remove current selections
        clearSelections(selections, true);
        // Focus options
        options.setFocus(true);
    }

    if (keycode == getNavigationSelectKey()) {
        // Prevent default behavior
        event.preventDefault();
        // Decide which select the selection was made in
        if (event.getSource() == options) {
            // Prevents the selection to become a single selection when
            // using Enter key as the selection key (default)
            options.setFocus(false);
            addItem();
        } else if (event.getSource() == selections) {
            // Prevents the selection to become a single selection when
            // using Enter key as the selection key (default)
            selections.setFocus(false);
            removeItem();
        }
    }
}
 
开发者ID:tepi,项目名称:ListBuilder,代码行数:41,代码来源:VListBuilder.java

示例11: onKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent event) {
	event.preventDefault();
	event.stopPropagation();
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:6,代码来源:SiteLoadingGlassPanel.java

示例12: handleKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@UiHandler("fileName")
void handleKeyDown(KeyDownEvent event) {
  int nativeKeyCode = event.getNativeKeyCode();
  switch (nativeKeyCode) {
    case KEY_UP:
      event.stopPropagation();
      event.preventDefault();
      if (list != null) {
        list.getSelectionModel().selectPrevious();
      }
      break;

    case KEY_DOWN:
      event.stopPropagation();
      event.preventDefault();
      if (list != null) {
        list.getSelectionModel().selectNext();
      }
      break;

    case KEY_PAGEUP:
      event.stopPropagation();
      event.preventDefault();
      if (list != null) {
        list.getSelectionModel().selectPreviousPage();
      }
      break;

    case KEY_PAGEDOWN:
      event.stopPropagation();
      event.preventDefault();
      if (list != null) {
        list.getSelectionModel().selectNextPage();
      }
      break;

    case KEY_ENTER:
      event.stopPropagation();
      event.preventDefault();
      SearchResultDto selectedItem = list.getSelectionModel().getSelectedItem();
      if (selectedItem != null) {
        delegate.onFileSelected(Path.valueOf(selectedItem.getItemReference().getPath()));
      }
      break;

    case KEY_ESCAPE:
      event.stopPropagation();
      event.preventDefault();
      hidePopup();
      break;
    default:
      // here need some delay to be sure input box initiated with given value
      // in manually testing hard to reproduce this problem but it reproduced with selenium tests
      new Timer() {
        @Override
        public void run() {
          String fileName = NavigateToFileViewImpl.this.fileName.getText();
          // Skip handling non letter characters.
          if (nativeKeyCode == KEY_BACKSPACE
              || nativeKeyCode == KEY_DELETE
              || fileName
                  .toLowerCase()
                  .contains(String.valueOf((char) nativeKeyCode).toLowerCase())) {
            delegate.onFileNameChanged(fileName);
          }
        }
      }.schedule(300);
      break;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:71,代码来源:NavigateToFileViewImpl.java

示例13: handleKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@UiHandler("nameField")
void handleKeyDown(KeyDownEvent event) {
  switch (event.getNativeKeyCode()) {
    case KeyCodes.KEY_UP:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectPrevious();
      break;

    case KeyCodes.KEY_DOWN:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectNext();
      break;

    case KeyCodes.KEY_PAGEUP:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectPreviousPage();
      break;

    case KeyCodes.KEY_PAGEDOWN:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectNextPage();
      break;

    case KeyCodes.KEY_ENTER:
      event.stopPropagation();
      event.preventDefault();
      delegate.onActionSelected(list.getSelectionModel().getSelectedItem());
      break;

    case KeyCodes.KEY_ESCAPE:
      event.stopPropagation();
      event.preventDefault();
      hide();
      break;
    default:
      // here we need some delay to be sure that input box initiated with given value
      // in manually testing hard to reproduce this problem but it reproduced with selenium tests
      new Timer() {
        @Override
        public void run() {
          delegate.nameChanged(nameField.getText(), includeNonMenu.getValue());
        }
      }.schedule(300);
      break;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:51,代码来源:FindActionViewImpl.java

示例14: handleKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@UiHandler("nameField")
void handleKeyDown(KeyDownEvent event) {
  switch (event.getNativeKeyCode()) {
    case KeyCodes.KEY_UP:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectPrevious();
      run(list.getSelectionModel().getSelectedItem(), false);
      return;

    case KeyCodes.KEY_DOWN:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectNext();
      run(list.getSelectionModel().getSelectedItem(), false);
      return;

    case KeyCodes.KEY_PAGEUP:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectPreviousPage();
      run(list.getSelectionModel().getSelectedItem(), false);
      return;

    case KeyCodes.KEY_PAGEDOWN:
      event.stopPropagation();
      event.preventDefault();
      list.getSelectionModel().selectNextPage();
      run(list.getSelectionModel().getSelectedItem(), false);
      return;

    case KeyCodes.KEY_ENTER:
      event.stopPropagation();
      event.preventDefault();
      run(list.getSelectionModel().getSelectedItem(), true);
      return;

    case KeyCodes.KEY_ESCAPE:
      event.stopPropagation();
      event.preventDefault();
      hide(true);
      return;
  }

  Scheduler.get()
      .scheduleDeferred(
          new Command() {
            @Override
            public void execute() {
              delegate.valueChanged(nameField.getText());
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:54,代码来源:QuickOpenViewImpl.java

示例15: handleKeyDown

import com.google.gwt.event.dom.client.KeyDownEvent; //导入方法依赖的package包/类
@Override
public void handleKeyDown(KeyDownEvent event) {
	boolean avoidBrowserDefault = true;
	if (Shortcut.DELETE_ELEMENT.matches(event)) {
		commandInvoker.removeSelectedElements(DrawPanel.this);
	}
	else if (Shortcut.DESELECT_ALL.matches(event)) {
		selector.deselectAll();
	}
	else if (Shortcut.SELECT_ALL.matches(event)) {
		selector.select(diagram.getGridElements());
	}
	else if (Shortcut.COPY.matches(event)) {
		commandInvoker.copySelectedElements(DrawPanel.this);
	}
	else if (Shortcut.CUT.matches(event)) {
		commandInvoker.cutSelectedElements(DrawPanel.this);
	}
	else if (Shortcut.PASTE.matches(event)) {
		commandInvoker.pasteElements(DrawPanel.this);
	}
	else if (Shortcut.SAVE.matches(event)) {
		mainView.getSaveCommand().execute();
	}
	else if (Shortcut.MOVE_UP.matches(event)) {
		keyboardMoveSelectedElements(0, -SharedConstants.DEFAULT_GRID_SIZE);
		redraw();
	}
	else if (Shortcut.MOVE_DOWN.matches(event)) {
		keyboardMoveSelectedElements(0, SharedConstants.DEFAULT_GRID_SIZE);
		redraw();
	}
	else if (Shortcut.MOVE_LEFT.matches(event)) {
		keyboardMoveSelectedElements(-SharedConstants.DEFAULT_GRID_SIZE, 0);
		redraw();
	}
	else if (Shortcut.MOVE_RIGHT.matches(event)) {
		keyboardMoveSelectedElements(SharedConstants.DEFAULT_GRID_SIZE, 0);
		redraw();
	}
	else if (Shortcut.DISABLE_STICKING.matches(event)) {
		SharedConfig.getInstance().setStickingEnabled(false);
	}
	else {
		avoidBrowserDefault = false;
	}

	// avoid browser default key handling for all overwritten keys, but not for others (like F5 for refresh or the zoom controls)
	if (avoidBrowserDefault) {
		event.preventDefault();
	}
}
 
开发者ID:umlet,项目名称:umlet,代码行数:53,代码来源:DrawPanel.java


注:本文中的com.google.gwt.event.dom.client.KeyDownEvent.preventDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。