本文整理汇总了Java中com.vaadin.client.WidgetUtil.focus方法的典型用法代码示例。如果您正苦于以下问题:Java WidgetUtil.focus方法的具体用法?Java WidgetUtil.focus怎么用?Java WidgetUtil.focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.client.WidgetUtil
的用法示例。
在下文中一共展示了WidgetUtil.focus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
import com.vaadin.client.WidgetUtil; //导入方法依赖的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();
}
}
}
示例2: focusInputField
import com.vaadin.client.WidgetUtil; //导入方法依赖的package包/类
private void focusInputField(Element componentElement) {
for (int i = 0; i < componentElement.getChildNodes().getLength(); i++) {
Node node = componentElement.getChildNodes().getItem(i);
if (node.getNodeName().equals("INPUT") || node.getNodeName().equals("SELECT")) {
WidgetUtil.focus((Element) node);
break;
}
}
}
示例3: focusInputField
import com.vaadin.client.WidgetUtil; //导入方法依赖的package包/类
/**
* Focus into input field below given element. Note! Element needs to be a
* table TD element so we don't mistakenly recurse too much.
*
* @param componentElement
* TD element to be searched for input and focused
* @param shiftKeyDown
* if shiftkey was down when event was triggered
*/
protected static void focusInputField(final Element componentElement, boolean shiftKeyDown) {
if (componentElement == null || !componentElement.getNodeName()
.equals("TD")) {
return;
}
Element input = getInputElement(componentElement.getChildNodes(), shiftKeyDown);
if (input != null) {
WidgetUtil.focus(input);
input.scrollIntoView();
}
}
示例4: restoreFocus
import com.vaadin.client.WidgetUtil; //导入方法依赖的package包/类
@Override
public void restoreFocus() {
WidgetUtil.focus(focus);
}
示例5: onKeyDown
import com.vaadin.client.WidgetUtil; //导入方法依赖的package包/类
@Override
public void onKeyDown(GridKeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
if (isCellContainingComponent(event.getFocusedCell())) {
// if the ENTER key-event's propagation is not stopped it would
// be propagated to the newly focused component, which e.g. in the
// case of a button leads to an immediate button press
event.preventDefault();
event.stopPropagation();
Element componentElement = extractComponentElement(event.getFocusedCell());
WidgetUtil.focus(componentElement);
focusInputField(componentElement);
}
}
}