當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。