ItemCount gives me the total items in a ListBox, RowCount gives me total number of rows in a ListBox. But ListBoxes can be scrolled. Is there a way to get the number of items actually shown in a ListBox ?
RowCount gives number of visible rows.
Manual is wrong again then it's not, you and I are saying the same thing with different wording:
https://github.com/adventuregamestudio/ags-manual/wiki/ListBox#rowcount
QuoteRowCount
readonly int ListBox.RowCount
Gets the number of rows that can be shown within the list box. This depends on the size of the list box, and does not depend on how many items are actually stored in the list box.
This property is read-only. To change the row count, adjust the height of the list box.
Example:
Display("You can currently see %d items from the listbox's contents", lstSaveGames.RowCount);
will display the number of rows that the listbox can display.
Edit: I did another test. I get the functionality described in the manual but I get a 0 on the first room load. Wait, now I see you and I talked about the same thing. The manual is correct.
Still, I don't know how to know if the page is scrolled.
Edit2:
_LIST BOX_
[ item a ]
[ item b ]
[ item c ]
[ ]
[ ]
[ ]
[ ]
__________
For a list box presented on the screen like the one "sketched" above, I need something that returns me 3, be the listbox scrolled or not. For the above, RowCount returns me 7.
So what does .ItemCount give? Should be 3, right?
Yes. I recorded a video - I really suck at writing... Notice the empty slot on the end.
(https://user-images.githubusercontent.com/2244442/62823796-93f96280-bb6b-11e9-89d9-1d35e7a20d03.gif)
Ok. I think I figured. There's a property I didn't knew called TopItem.
int VisibleItemCount(this ListBox*){
int d = this.ItemCount - this.TopItem-1;
if(d < this.RowCount){
return d;
}
return this.RowCount;
}
Oh, you were asking about items actually visible at the moment, that's weird but somehow I misunderstood.