TreeView scrolling

Hello!

I can’t seem to find a way to detect if a TreeView has been scrolled. The only thing I can see is to attach a ScrollBar::Listener, but this only detects direct user manipulation of the ScrollBar, which isn’t enough.

To save on boring words, here’s a quick image of my layout:

i.e. a TreeView and a TableListBox married together, with the vertical scrollbar disabled on the TreeView.

I can keep the TreeView in sync with the TableListBox easily enough (albeit awkwardly, via TableListBoxModel::listWasScrolled). However, if the user scrolls* through the TreeView itself, I can’t see anything to respond to.

I know that Viewport has a virtual interface to respond to its changes (which is what I’m really interested in), but the problem here is that these components provide their own Viewport, so I cannot override them.

I can see two solutions, really:

  1. Add a Viewport::Listener class
  2. Add callbacks to these components to respond to viewport changes

Any thoughts?

[size=85]*There’s also the fact that the user can’t actually mouse-scroll the TreeView when the scrollbar is disabled (except with the cursor keys), which I’d like to find a solution for, but I’m not too worried about that right now.
[/size]

I guess I should probably have called the thread ‘Is there any chance of a Viewport::Listener class?’

Can’t you get the same effect by adding a ComponentListener to the viewed comp and seeing when it moves? IIRC the viewport works by just moving that component around, so you should be able to catch it doing that.

That is precisely the sort of logical leap I was missing! :smiley: thank you!