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


Java KeyPressEvent类代码示例

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


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

示例1: addEnterTarget

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
/**
 * Adds a {@link KeyPressHandler} to the specified widget which calls {@link Button#click()} on <code>targetButton</code>
 * when the Enter key is pressed.
 * @param widget       widget to add the key handler to
 * @param targetButton target button to activate when the enter key is pressed
 */
public static void addEnterTarget( final HasKeyPressHandlers widget, final Button targetButton ) {
	widget.addKeyPressHandler( new KeyPressHandler() {
		@Override
		public void onKeyPress( final KeyPressEvent event ) {
			if ( event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER )
				targetButton.click();
		}
	} );
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:16,代码来源:ClientUtils.java

示例2: replace_foundElement

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
@Test
public void replace_foundElement() {
    // given
    TextBoxMock hasValue = mock(TextBoxMock.class);
    when(hasValue.getValue()).thenReturn("a");
    ExpressionReplacer replacer = new ExpressionReplacer();
    replacer.useReplacements(ImmutableMap.of("a", "b", "c", "d"));

    KeyPressEvent event = mock(KeyPressEvent.class);
    when(event.getCharCode()).thenReturn("a".charAt(0));

    ArgumentCaptor<InputEventListener> listenerCaptor = ArgumentCaptor.forClass(InputEventListener.class);
    handler.init(Wrapper.of(hasValue), replacer);
    verify(eventRegistrar).registerInputHandler(eq(hasValue), listenerCaptor.capture());

    // when
    listenerCaptor.getValue().onInput();

    // then
    verify(hasValue).setValue("b", true);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:22,代码来源:ReplacingChangeHandlerJUnitTest.java

示例3: install

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:FocusManager.java

示例4: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
public void onKeyPress(KeyPressEvent event) {
  ChartState chartInfo = getChartState(event);

  Chart chart = chartInfo.chart;

  int keyCode = event.getCharCode();
  boolean handled = true;
  if (keyCode == KeyCodes.KEY_TAB) {
    handled = handleTabKey((Event)event.getNativeEvent(), chartInfo, keyCode, event.isShiftKeyDown());
  } else if (keyCode == KEY_Z) {
    chart.nextZoom();
  } else if (keyCode == KEY_X) {
    chart.prevZoom();
  } else if (keyCode == KeyCodes.KEY_ENTER) {
    chart.maxZoomToFocus();
  } else {
    handled = false;
  }

  chartInfo.setHandled(handled);
  if (handled) {
      event.stopPropagation();
      event.preventDefault();
  }
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:26,代码来源:ChartKeyPressHandler.java

示例5: onKeyPress

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
public void onKeyPress(KeyPressEvent arg0) {
	if (arg0.getCharCode() == KeyCodes.KEY_ENTER) {
		
		Long candidateID = null;
		
		try{
			candidateID = Long.parseLong(addCandidateIdTB.getText());
		}  catch(NumberFormatException e) {
			BallotServer.popError("The Candidate ID must be a number.");
			return;
		}
		
		Communicator.getInstance().getService().addCandidate(electionId, 
				addCandidateNameTB.getText(), candidateID,
				new UpdateCallback());
	}
}
 
开发者ID:nmldiegues,项目名称:easy-vote,代码行数:18,代码来源:ElectionWidget.java

示例6: createCurPageBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
/**
 * Create a box that holds the current page.
 */
private void createCurPageBox() {
    // Setup the widget
    curPageBox.setWidth("3em");
    curPageBox.setText("1");
    curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);

    // Disallow non-numeric pages
    KeyPressHandler handler = new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {

            int keyCode = event.getNativeEvent().getKeyCode();
            char charCode = event.getCharCode();
            if (keyCode == KeyCodes.KEY_ENTER) {
                PagingPanel.this.table.gotoPage(getPagingBoxValue(), false);
            } else if (charCode != 0 && !Character.isDigit(charCode)) {
                    curPageBox.cancelKey();
            }
        }
    };

    // Add the handler
    curPageBox.addKeyPressHandler(handler);
}
 
开发者ID:lsst,项目名称:firefly,代码行数:27,代码来源:PagingPanel.java

示例7: onLoad

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
@Override
protected void onLoad() {
  super.onLoad();
  if (regFocus == null) {
    regFocus =
        GlobalKey.addApplication(
            this,
            new KeyCommand(0, '/', Gerrit.C.keySearch()) {
              @Override
              public void onKeyPress(KeyPressEvent event) {
                event.preventDefault();
                searchBox.setFocus(true);
                searchBox.selectAll();
              }
            });
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:SearchPanel.java

示例8: registerKeys

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
@Override
public void registerKeys() {
  super.registerKeys();

  getKeysNavigation()
      .add(
          new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_LEFT, PatchUtil.C.focusSideA()),
          new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_RIGHT, PatchUtil.C.focusSideB()));
  getKeysAction()
      .add(
          new KeyCommand(KeyCommand.M_SHIFT, 'a', PatchUtil.C.toggleSideA()) {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              diffTable.toggleA().run();
            }
          });

  registerHandlers();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:SideBySide.java

示例9: setupNav

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
private KeyCommand setupNav(InlineHyperlink link, char key, String help, FileInfo info) {
  if (info != null) {
    final String url = url(info);
    link.setTargetHistoryToken(url);
    link.setTitle(
        PatchUtil.M.fileNameWithShortcutKey(
            FileInfo.getFileName(info.path()), Character.toString(key)));
    KeyCommand k =
        new KeyCommand(0, key, help) {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            Gerrit.display(url);
          }
        };
    keys.add(k);
    if (link == prev) {
      hasPrev = true;
    } else {
      hasNext = true;
    }
    return k;
  }
  link.getElement().getStyle().setVisibility(Visibility.HIDDEN);
  keys.add(new UpToChangeCommand(projectKey, patchSetId, 0, key));
  return null;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:Header.java

示例10: setKeyTyped

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
public void setKeyTyped(JavaScriptObject aValue) {
	if (keyTyped != aValue) {
		if (keyTypedReg != null) {
			keyTypedReg.removeHandler();
			keyTypedReg = null;
		}
		keyTyped = aValue;
		if (keyTyped != null && component instanceof HasKeyPressHandlers) {
			keyTypedReg = ((HasKeyPressHandlers) component).addKeyPressHandler(new KeyPressHandler() {
				@Override
				public void onKeyPress(KeyPressEvent event) {
					if (keyTyped != null) {
						event.stopPropagation();
						executeEvent(keyTyped, EventsPublisher.publish(event));
					}
				}
			});
		}
	}
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:21,代码来源:EventsExecutor.java

示例11: bind

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
public void bind() {
	RootPanel.get("container").add(getView().asWidget());
	getView().asWidget().setVisible(false);
	view.getLoginButton().addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent arg0) {
			login();
		}
	});

	KeyPressHandler handler = new KeyPressHandler() {

		@Override
		public void onKeyPress(KeyPressEvent event) {
			// Si on appuie sur "Entrée"
			if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode())
				login();
		}
	};

	getView().getLoginKeyPress().addKeyPressHandler(handler);
	getView().getPasswdKeyPress().addKeyPressHandler(handler);
	getView().asWidget().setVisible(true);
}
 
开发者ID:guiguib,项目名称:yaph,代码行数:26,代码来源:LoginPresenter.java

示例12: createOnKeyPressListener

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
public static KeyPressHandler createOnKeyPressListener(final EventListenerGVO ev, final List<InputVariableGVO> input) {
	return new KeyPressHandler() {
		public void onKeyPress(KeyPressEvent event) {
			if (ev.getParameterList() != null) {
				Iterator<ParameterGVO> itr = ev.getParameterList().iterator();
				while (itr.hasNext()) {
					ParameterGVO parameter = itr.next();
					if (parameter != null) {
						if (KeyBoardHelper.isKeyInput(parameter.getName(), parameter.getValue(), Character.toString(event.getCharCode()))) {
							CallbackHandler.createCallBack(event.getSource(), QAMLConstants.EVENT_ONKEYPRESS, ev, input);
						}
					}
				}
			}
		}
	};
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:18,代码来源:EventFactory.java

示例13: createCurPageBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
/**
 * Create a box that holds the current page.
 */
private void createCurPageBox() {
	// Setup the widget
	curPageBox.setWidth("3em");
	curPageBox.setText("1");
	curPageBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);

	// Disallow non-numeric pages
	KeyPressHandler handler = new KeyPressHandler() {
		public void onKeyPress(KeyPressEvent event) {
			char charCode = event.getCharCode();
			if (charCode == KeyCodes.KEY_ENTER) {
				QPagingOptions.this.table.gotoPage(getPagingBoxValue(), false);
			} else if (!Character.isDigit(charCode) && (charCode != KeyCodes.KEY_TAB) && (charCode != KeyCodes.KEY_BACKSPACE) && (charCode != KeyCodes.KEY_DELETE) && (charCode != KeyCodes.KEY_ENTER) && (charCode != KeyCodes.KEY_HOME) && (charCode != KeyCodes.KEY_END) && (charCode != KeyCodes.KEY_LEFT) && (charCode != KeyCodes.KEY_UP) && (charCode != KeyCodes.KEY_RIGHT) && (charCode != KeyCodes.KEY_DOWN)) {
				curPageBox.cancelKey();
			}
		}
	};

	// Add the handler
	curPageBox.addKeyPressHandler(handler);
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:25,代码来源:QPagingOptions.java

示例14: createKeyPressHandler

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
private static KeyPressHandler createKeyPressHandler(final ComponentGVO componentGVO, final EventListenerGVO eventGVO, final NotifyHandler notifyHandler, final String windowId, final String context, final AbstractActivity activity) {
	return new KeyPressHandler() {
		@Override
		public void onKeyPress(KeyPressEvent event) {
			if (eventGVO.getParameterList() == null) {
				return;
			}
			Iterator<ParameterGVO> itrParameter = eventGVO.getParameterList().iterator();
			while (itrParameter.hasNext()) {
				ParameterGVO parameterGVO = itrParameter.next();
				if (parameterGVO == null) {
					continue;
				}
				if (KeyBoardHelper.isKeyInput(parameterGVO.getName(), parameterGVO.getValue(), Character.toString(event.getCharCode()))) {
					UIObject widget = (UIObject)event.getSource();
					List<InputVariableGVO> inputVariables = eventGVO.getInputvariablesList();
					handleEvent(componentGVO, widget, eventGVO, event, QAMLConstants.EVENT_ONKEYPRESS, inputVariables, notifyHandler, windowId, context, activity);
					break;
				}
			}
		}
	};
}
 
开发者ID:qafedev,项目名称:qafe-platform,代码行数:24,代码来源:ActivityHelper.java

示例15: onSearchBox

import com.google.gwt.event.dom.client.KeyPressEvent; //导入依赖的package包/类
@UiHandler("searchBox")
void onSearchBox(KeyPressEvent event) {
	final InputText source = (InputText) event.getSource();
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {

		@Override
		public void execute() {
			String query = source.flush();
			if (query == null || query.length() == 0) {
				displayList(displayedList);
			} else {
				final String queryToCompare = query.toLowerCase().trim();
				Iterable<Contact> filteredIteable = Iterables.filter(displayedList, new Predicate<Contact>() {

					@Override
					public boolean apply(Contact contact) {
						return contact.getName() != null && contact.getName().toLowerCase().contains(queryToCompare);
					}
				});
				displayList(Lists.newArrayList(filteredIteable));
			}
		}
	});
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:25,代码来源:AddressBookView.java


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