Get last selected item in wxLB_MULTIPLE kind of wxListBox Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Get last selected item in wxLB_MULTIPLE kind of wxListBox

Post by Tapsa » Mon Jun 08, 2015 2:22 pm

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?

User avatar
doublemax
Moderator
Moderator
Posts: 15174
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Post by doublemax » Mon Jun 08, 2015 4:47 pm

wxListBox::HitTest() can give you both.
Use the source, Luke!

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Post by Tapsa » Mon Jun 08, 2015 5:32 pm

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 :)

User avatar
doublemax
Moderator
Moderator
Posts: 15174
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Get last selected item in wxLB_MULTIPLE kind of wxListBox

Post by doublemax » Mon Jun 08, 2015 5:43 pm

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).
Use the source, Luke!

Post Reply