ListBox + scroll: Index of mouse-focused item?

only_a_ptr

29-06-2015 23:43:51

Hello.

I need to retrieve an index of mouse-hovered ListBox item, in a scenario where the ListBox needs scrolling (i.e. all items don't fit in the widget dimensions at once). What is the recommended way to do this, please?

The obvious choice seems to be eventListMouseItemFocus, but in the version which I tested (mygui-trunk-r4359, 2012-01) this function is either buggy or strangely designed - the "index" parameter does not represent item's position in the entire list, but rather just item's position in currently screen-visible portion of the list (i.e. no matter where you scroll, the first item visible on screen always returns 0)

-------------------------
EDIT:
I looked into the sources. Obviously, ListBox keeps all items (name+userdata) in mItemsInfo and dynamically creates widgets for screen-visible lines only: https://github.com/MyGUI/mygui/blob/mas ... x.cpp#L311 (variable mWidgetLines). The "index" parameter eventListMouseItemFocus is an index in mWidgetLines. Nice.
Upon building mWidgetLines, ListBox forwards their notifyMouseSetFocus + notifyMouseLostFocus events to it's own delegates. However, it seems userdata are not copied from mItemsInfo to mWidgetLines, so the event's _sender widget cannot be determined, except by name (string comparsion).

Did I miss something or is this a bug?