[haiku-development] Re: Query about BOutlineListView

  • From: Zenja Solaja <solaja@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 6 Apr 2024 16:05:05 +0200

Hi Maximo

This wont work since BOutlineListView is a tree, so the full list index
(eg. 22) doesnt map to a branch BListView subindex with a smaller number of
elements. This was the first thing I tried and immediate got an out of
bounds access error.

BListView Select(idx) wont work for trees. I’m only limited to
BOutlineListView::FullListItemAt(idx) pointers, but that wont allow me to
set the private fLastSelected which is used to remove highlight when the
mouse selects another item.

Hence my request for FullListSelectItem(idx) which can access the correct
internal BListView select(subindex) method.

On Sat, 6 Apr 2024 at 13:23, Máximo Castañeda <dmarc-noreply@xxxxxxxxxxxxx>
wrote:

 En viernes, 5 de abril de 2024, 19:35:22 CEST, Zenja Solaja <
solaja@xxxxxxxxx> escribió:

I have a BOutlineListView, where on program start I want to
select/highlight an item.

The BListView base class has a Select(index) method, which also sets
private fLastSelected. This is used to turn off highlight on subsequent
invocation.

Sadly, there is no FullListSelectItem(index) for the derived class
BOutlineListView().  The index parameter is mapped differently for a tree
structure, so I cannot call the appropriate Select(actual index) function.

[...]
Long story short, FullListSelectItem(index) would solve this, but it
doesn’t exist for BOutlineListView.


If I understand you correctly, you are asking for a fullIndex -> showIndex
translation.

BListItem* itemToSelect = list.FullListItemAt(fullIndex);
int32 showIndex = list.IndexOf(itemToSelect);
list.Select(showIndex);

You may want to check return values, and maybe call list.Expand(item)
before getting its index.


Other related posts: