[haiku-development] Re: Query about BOutlineListView

  • From: "Máximo Castañeda" <dmarc-noreply@xxxxxxxxxxxxx> ("antiswen")
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Sat, 6 Apr 2024 11:23:04 +0000 (UTC)

 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: