Page 1 of 1

wxRearrangeCtrl: Howto catch select event

Posted: Sat Aug 31, 2019 8:02 am
by vanarieleyen
I am stuck with a simple problem...

I have a wxRearrangeCtrl and would like to perform some additional action when I click on a list item.

Here is some code:

const long MY_ID = wxNewId();

wxRearrangeCtrl * arrange = new wxRearrangeCtrl(parent, MY_ID, pos, size, order, items, style, validator, name);

Connect(MY_ID, wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction)&OnSelectClick);

void OnSelectClick(wxCommandEvent& event) {
wxMessageBox("OK");
}

The arrangebox is working well. It is shown and I can arrange the items.
However when I select an item I would like to perform some extra code but the event is never fired.

I guessed I had to subclass wxRearrangeCtrl which I did, but how to go further?

Re: wxRearrangeCtrl: Howto catch select event

Posted: Sat Aug 31, 2019 10:11 am
by doublemax
The problem is that wxRearrangeCtrl is a composite control, it contains multiple other controls internally. And the ID "MY_ID" that you assign for the wxRearrangeCtrl, will not be used for the internal wxListBox. So, either use wxID_ANY for the ID in the Connect call, or retrieve the correct ID from the internal control using arrange->GetList()->GetId()

Re: wxRearrangeCtrl: Howto catch select event

Posted: Wed Sep 04, 2019 12:56 am
by vanarieleyen
Just to tell you that your suggestion worked :D

I also wanted to do this so I had already made a class that inherits from wxRearrangeCtrl but I didn't know how to get the id from the list. I searched the wx doc's but nowhere is GetId() mentioned...