MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / selectElement

Method selectElement

CodenameOne/src/com/codename1/ui/List.java:1002–1021  ·  view source on GitHub ↗
(int selectedIndex)

Source from the content-addressed store, hash-verified

1000 }
1001
1002 void selectElement(int selectedIndex) {
1003 Dimension size = getElementSize(false, true);
1004 Rectangle rect;
1005 if (getOrientation() != HORIZONTAL) {
1006 rect = new Rectangle(getX(), (size.getHeight() + itemGap) * selectedIndex, getElementSize(true, true));
1007 } else {
1008 int x = (size.getWidth() + itemGap) * selectedIndex;
1009 if (isRTL() && isScrollableX()) {
1010 x = getScrollDimension().getWidth() - x - (size.getWidth() + itemGap);
1011 }
1012 rect = new Rectangle(x, getY(), getElementSize(true, true));
1013 }
1014 if (hasScrollableParent(getParent())) {
1015 if (hasFocus()) {
1016 scrollRectToVisible(rect);
1017 }
1018 } else {
1019 scrollRectToVisible(rect);
1020 }
1021 }
1022
1023 private boolean hasScrollableParent(Container c) {
1024 if (c == null) {

Callers 3

laidOutMethod · 0.95
setSelectedIndexMethod · 0.95
keyPressedMethod · 0.95

Calls 14

getElementSizeMethod · 0.95
getOrientationMethod · 0.95
getHeightMethod · 0.95
getWidthMethod · 0.95
isScrollableXMethod · 0.95
hasScrollableParentMethod · 0.95
scrollRectToVisibleMethod · 0.95
hasFocusMethod · 0.80
getXMethod · 0.65
getWidthMethod · 0.65
getYMethod · 0.65
getParentMethod · 0.65

Tested by

no test coverage detected