Hbox horizontalScrollPosition not working - apache-flex

I am applying hb.horizontalScrollPosition = value and it does not work with horizonalScrollPolicy = on/off. Is there any other way to achieve this?
Thanks.

When exactly are you setting the scroll position relative to loading the content? Perhaps the content isn't measured yet. Try using callLater to wait a frame before setting the scroll position.

Related

QSlider makes unnecessary steps

I am trying to use a QSlider, but if somebody clicks on a position X, where he wants to put the slider to, the slider always sets the value to maximum or minimum at first and then to the value X. So there is an unnecessary step in-betweeen.
How can I avoid this step?
I implemented the slider with the help of QTDesigner.
The code for the remaining setup is the following:
_ui->horizontalSlider->setRange(1, aMaximalValue);
_ui->horizontalSlider->setValue(theCurrentValue);
connect(_ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onValueOfSliderChanged(int)));
When using a QSlider, my experience says that when you click at a certain position in the slider which is to right of current position(considering horizontal slider), it will increase slider value by pageStep size. Similarly, if click value is to left of current position, it will decrease slider value by pageStep size. Only when you drag the slider to that place, it will set the value to what you want and not on clicking. Try setting the pageStep size to see if this is the issue.
Yes, just like shubh explained, the pagestep is probably too large. A common issue with QSliders is that they do not jump to the position you have clicked, but move a pagestep in that direction.
A solution to that problem has been described in this question

Removing the Scrollbar from Horizontal List

I've got an Horizontal List. It contains 6 XML Nodes at the moment. But what I'd like to do is remove the scrollbar so that an button can function to scroll through the nodes instead.
Has anyone achieved this, if so how did you go about it?
Thanks in advance
You can usually remove the scroll bar by setting the horizontalScrollPolicy or verticalScrollPolicy to off.
After that, I believe you can scroll the list by setting the verticalScrollPosition or horizontalScrollPosition

In flex, how to get correct Y-axis when there is a vertical scroll?

In flex, I am getting the y-coordinate in the following way:
nextHBox = HBox(ingBox.getChildByName("ing" + nextId));
nextYAxis = ingBox.localToGlobal(new Point(nextHBox.x,nextHBox.y)).y;
newCanvas.x = nextYAxis;
nextYAxis gives me the y-axis and I use it to position new component. It works absolutely fine. But, when there is vertical scroll, and I scroll it a little bit, and then the above mentioned code places the component at wrong place. I believe, it has something to do with the scroll.
You can factor in the scroll position of the parent container by adding the value of its verticalScrollPosition property to your y position.

Flex 3: HBox children Scrolling with buttons

I have an HBox with width=500.
I actually want to add two arrows buttons that will scroll the contents of the HBox.
But when I turn HBox's scroll policy to off, I can't scroll it programmatically using horizontalScrollPosition.
What should i do now?
Thanks
I've hacked together this custom HBox that you could use. Simply set horizontalScrollPolicy to either "on" or "auto". I really haven't tested it all that much, works for a simple test I did...
public class CustomHBox extends HBox
{
override public function validateDisplayList():void
{
super.validateDisplayList();
if (horizontalScrollBar)
horizontalScrollBar.visible = false;
}
}
Scroll bars will not be displayed when scrollPolicy is turned off.
I think for what you want, you want to subclass ScrollBar make it look and feel the way you would like, then set it on your Container.horizontalScrollBar
I'm no Flex expert, but this is possible without too much trouble (using Flex SDK 3.2, anyway). You're right - when you turn off the horizontalScrollPolicy, the maxHorizontalScollPosition is set to 0, UNLESS you specify both a width value AND a maxWidth value. Then, maxHorizontalScrollPosition will again contain a useable value, and you'll be able to programmatically set the horizontalScrollPosition.

Centering item renderers in a HorizontalList

I am trying to center itemRenderers in a horizontal list if the number of items in the list is less than the maximum visible number. Has anyone found a good way to do this?
See an illustration of what I mean if it is hard to picture.
Thanks!
Override the measure() method - I've writen a blog entry here: http://flexmonkey.blogspot.com/2010/05/centre-aligned-horizontallist-in-flex.html
simon
One solution that comes to mind would be to add invisible renderers to achieve the same centering.
You might want to consider using a horizontal box or "Hbox" instead of a horizontal list component. This will allow you to use the horizontal align property to set center. If not, simply extend the horizontal list component to accept a center align property, and copy it from the hbox to your new extended component.
Would paddingRight or paddingLeft accomplish what you're looking for? If you combine it with setting the columnWidth and the columnCount, that would allow you to adjust where the items first appear.

Resources