Page 1 of 1

Get last selected item in wxLB_MULTIPLE kind of wxListBox

Posted: Mon Jun 08, 2015 2:22 pm
by Tapsa
And when I have many items selected, I want to get the item I am clicking, even if I click on already selected item.
Also, how do I get the first visible item?

Does Windows have API to get these?

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Posted: Mon Jun 08, 2015 4:47 pm
by doublemax
wxListBox::HitTest() can give you both.

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Posted: Mon Jun 08, 2015 5:32 pm
by Tapsa
Thanks. I don't quite understand what it does. It seems to me that I tell the function to look if an item exists at a place.
I don't know what item number the first visible is from my code. Should HitTest be called with 0 0 in that case?
I currently have no clue what is the purpose of HitTest. Why are there two parameters, when a list only has one coordinate?

I googled some code and it looks like I need to pull info from event object.
Compiler says that wxCommandEvent does not have GetPosition, so what do I pull into HitTest?

I figured out that I can get the last selected item simply from event object :)

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Posted: Mon Jun 08, 2015 5:43 pm
by doublemax
I currently have no clue what is the purpose of HitTest. Why are there two parameters, when a list only has one coordinate?
It gets mouse coordinates (relative to the window) as input and finds the item number under the mouse.

With passing (0,0) you should get the first visible item. (Try passing (1,1) or similiar if it doesn't work).