FileTreeComponent / TreeView and horizontal scrollbars?


#1

Is it possible to have an horizontal scrollbar for the FileTreeComponent/TreeView?

If not, I guess I will need to use a viewport and a fixed extra size just for that.

Anyway, thanks for any advice.

Cheers, WilliamK


#2

Ok, I found a way that works, just hope it is correct. :wink:

I added to my component.

void componentMovedOrResized(Component& component, bool wasMoved, bool wasResized);
Viewport* extraViewPort;

And also added public ComponentListener

Now I create it and add the TreeView to the ViewPort.

extraViewPort = new Viewport("ExtraViewPort");
addAndMakeVisible(extraViewPort);
extraViewPort->setViewedComponent(treeView, true);
treeView->getViewport()->getViewedComponent()->addComponentListener(this);
treeView->getViewport()->setScrollBarsShown(false, false);

treeView is the actual FileTreeComponent / TreeView

Now I add

void componentMovedOrResized(Component& component, bool wasMoved, bool wasResized)
{
	Point<int> xPos = extraViewPort->getViewPosition();
	treeView->setBounds(0, 0, 800, treeView->getViewport()->getViewedComponent()->getHeight());
	extraViewPort->setViewPosition(xPos);
}

Works correctly so far. :wink: The Width is fixed, so I just add around 400 extra pixels for it, which should be enough.

Cheers, WilliamK