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


Java KeyCodes.maybeSwapArrowKeysForRtl方法代码示例

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


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

示例1: onBrowserEvent

import com.google.gwt.event.dom.client.KeyCodes; //导入方法依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
    if (getElement() == DOM.eventGetTarget(event)) {
        return;
    }

    SuggestionItem item = findItem(DOM.eventGetTarget(event));
    switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEDOWN: {
            if (BrowserInfo.get().isIE()) {
                suggestionFieldWidget.iePreventBlur = true;
            }
            break;
        }

        case Event.ONCLICK: {
            if (event.getButton() == NativeEvent.BUTTON_LEFT) {
                performItemCommand(item);
            }
            break;
        }

        case Event.ONMOUSEOVER: {
            if (item != null) {
                selectItem(item);
            }
            break;
        }

        case Event.ONKEYDOWN: {
            int keyCode = KeyCodes.maybeSwapArrowKeysForRtl(
                    event.getKeyCode(),
                    LocaleInfo.getCurrentLocale().isRTL()
            );

            switch (keyCode) {
                case KeyCodes.KEY_UP:
                    selectPrevItem();
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_DOWN:
                    selectNextItem();
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_ESCAPE:
                    selectItem(null);
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_TAB:
                    selectItem(null);
                    break;
                case KeyCodes.KEY_ENTER:
                    performItemCommand(item);
                    preventEvent(event);
                    break;
            }
            break;
        }
    }
    super.onBrowserEvent(event);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:62,代码来源:SuggestionsContainer.java

示例2: _keyboardNavigation

import com.google.gwt.event.dom.client.KeyCodes; //导入方法依赖的package包/类
private void _keyboardNavigation(final Event event) {
	// Handle keyboard events if keyboard navigation is enabled
	if (this.isKeyboardNavigationEnabled(_focusedItem)) {
		int code = event.getKeyCode();

		switch (KeyCodes.maybeSwapArrowKeysForRtl(code,LocaleInfo.getCurrentLocale().isRTL())) {
		case KeyCodes.KEY_UP: {
			List<TreeViewItem> slibingsBefore = _focusedItem.getSiblingsBefore();
			if (slibingsBefore != null) {
				_onFocus(slibingsBefore.get(slibingsBefore.size()-1));
			} else if (_focusedItem.getDirectAncestor() != null) {
				_onFocus(_focusedItem.getDirectAncestor());
			}
			break;
		}
		case KeyCodes.KEY_DOWN: {
			List<TreeViewItem> slibingsAfter = _focusedItem.getSiblingsAfter();
			if (slibingsAfter != null) {
				_onFocus(slibingsAfter.get(0));
			} else {
				TreeViewItem focusedItemAncestor = _focusedItem.getDirectAncestor();
				while (focusedItemAncestor != null && focusedItemAncestor.getNextSibling() == null) {
					focusedItemAncestor = focusedItemAncestor.getDirectAncestor();
				}
				if (focusedItemAncestor != null && focusedItemAncestor.getNextSibling() != null) _onFocus(focusedItemAncestor.getNextSibling());
			}
			break;
		}
		case KeyCodes.KEY_LEFT: {
			if (_focusedItem.getDirectAncestor() == null) return;
			_onFocus(_focusedItem.getDirectAncestor());
			break;
		}
		case KeyCodes.KEY_RIGHT: {
			if (!_focusedItem.hasChildren()) return;
			if (_focusedItem.isCollapsed()) _focusedItem.expand();	
			_onFocus(_focusedItem.getChildAt(0));	// move focus
			break;
		}
		default: {
			return;
		}
		}
	}
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:46,代码来源:TreeView.java


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