Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

TileGroup and ensureElementIsVisible

$
0
0
I am testing a programmatic scrolling of TileGroup. Either I am doing
something wrong or there is bug here. I am providing code for testing.
When you run it you will see rows of buttons and a scroller. Click on
button 1 and start tabbing. When it reaches button 4 and you tab again it
will go to button 5 which is in the next row that is not fully shown but no
scrolling will occur. Going to the next button (number 6) will scroll it
up. But it should have scrolled it when a focus was moved to the number 5.
Hope, it's clear.

<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" height="80"

<fx:Script>
<![CDATA[
import mx.core.ILayoutElement;
import mx.core.IVisualElement;
private function init():void

for (var i:int=0;i<tl.numElements;i++)

var element:ILayoutElement = tl.getElementAt(i);
element.addEventListener(KeyboardEvent.KEY_DOWN, onFocusOut, false, 0,
true);

private function onFocusOut(event:KeyboardEvent):void

if (event.keyCode == 9)
ensureVisible(event.target as Button);

private function ensureVisible(target:Button):void

trace(target.label);
scroller.ensureElementIsVisible(target as IVisualElement);

]]>
</fx:Script>
<s:Scroller height="100%" id="scroller">
<s:VGroup height="100%">
<s:TileGroup horizontalGap="1" verticalGap="1" creationComplete="init()"
requestedColumnCount="4" id="tl">
<s:Button label="1" width="50" height="50" />
<s:Button label="2" width="50" height="50" />
<s:Button label="3" width="50" height="50" />
<s:Button label="4" width="50" height="50" />
<s:Button label="5" width="50" height="50" />
<s:Button label="6" width="50" height="50" />
<s:Button label="7" width="50" height="50" />
<s:Button label="8" width="50" height="50" />
<s:Button label="9" width="50" height="50" />
</s:TileGroup>
</s:VGroup>
</s:Scroller>
</s:Application>

Thanks

Viewing all articles
Browse latest Browse all 5648

Trending Articles