And if I want my derived control to save selected items, how can I know that shift key was used to selected several items at once?
I assume that selection event has stored the selected index that I could use, but probably skipping items selected using shift key.
What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED? Topic is solved
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
wxEVT_COMMAND_LISTBOX_SELECTED ~ wxEVT_LIST_ITEM_SELECTED
With wxListCtrl::GetSelectedItemCount() you get the total number of selected items.
With wxListCtrl::GetNextItem() you can get all selected items in a loop.
http://docs.wxwidgets.org/trunk/classwx ... 89caa32e78
With wxListCtrl::GetSelectedItemCount() you get the total number of selected items.
With wxListCtrl::GetNextItem() you can get all selected items in a loop.
http://docs.wxwidgets.org/trunk/classwx ... 89caa32e78
Use the source, Luke!
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
Thanks. I got the next item code to work (though from an event hooked to wxListBox). I get
Can connect be used with wxListEvents?
It looks like wxWidgets 2.8 has wxEVT_COMMAND_LIST_ITEM_SELECTED.
with the following code and I do have <wx/listctrl.h> included.error: 'wxEVT_LIST_ITEM_SELECTED' was not declared in this scope
Code: Select all
Connect(Graphics_Graphics_ListV->GetId(), wxEVT_LIST_ITEM_SELECTED , wxListEventHandler(AGE_Frame::OnGraphicsSelect));
It looks like wxWidgets 2.8 has wxEVT_COMMAND_LIST_ITEM_SELECTED.
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
If you're using 2.8 you have to use wxEVT_COMMAND_LIST_ITEM_SELECTED indeed.It looks like wxWidgets 2.8 has wxEVT_COMMAND_LIST_ITEM_SELECTED.
Use the source, Luke!
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
While that kinda solves my original question, that event doesn't catch selection changes when deselecting or when selecting many items with shift button down. I was looking for one event to rule them all. I guess I can write a wrapper that connects all the necessary events. During my short affair with Qt I faced the same problem and I had to connect the underlaying selection model, but it had selectionChanged event that covered all my use cases.
I also find it annoying that I can't select many items just by holding down left mouse button, like I can with wxListBox.
And I would like the column width to always be the width of the text control.
I also find it annoying that I can't select many items just by holding down left mouse button, like I can with wxListBox.
And I would like the column width to always be the width of the text control.
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
I just tested this with the "listctrl" sample in 2.8.12 and 3.0.2. I always get Selection/Deselection events, even when the Shift-key was used to select multiple items.that event doesn't catch selection changes when deselecting or when selecting many items with shift button down.
Use the source, Luke!
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
Did you treat it as a wxListEvent or wxCommandEvent? It looks like both can be applied and the result is same.
It's time for me to write some wrapper function then.
This is my simple list control class. Perhaps it's those style flags
Seeing that there are both EVT_LIST_ITEM_SELECTED and EVT_LIST_ITEM_DESELECTED macros and that the documentation doesn't have other selection event macros, I think EVT_LIST_ITEM_SELECTED is meant to only process basic left mouse button clicks that make an item selected. In short, there is no equivalent for wxEVT_COMMAND_LISTBOX_SELECTED in wxListCtrl.
It's time for me to write some wrapper function then.
This is my simple list control class. Perhaps it's those style flags
Code: Select all
class AGEListView: public wxListCtrl
{
public:
AGEListView(wxWindow *parent, const wxSize &size):
wxListCtrl(parent, wxID_ANY, wxDefaultPosition, size, wxLC_VIRTUAL | wxLC_REPORT | wxLC_NO_HEADER)
{
SetItemCount(0);
InsertColumn(0, wxEmptyString, wxLIST_FORMAT_LEFT, 200);
}
wxArrayString names;
vector<int> indexes;
private:
virtual wxString OnGetItemText(long item, long column) const;
};
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
Yes, in virtual mode the situation is different. The only event you can use in this case is wxEVT_LIST_ITEM_FOCUSED.
Use the source, Luke!
Re: What is the wxListCtrl equivalent of wxEVT_COMMAND_LISTBOX_SELECTED?
Fantastic! It seems to fire exactly when I need it to. Not firing on mouse hover