Connecting wxRibbonButtonBar Events
Posted: Fri Mar 22, 2013 11:17 pm
I feel connecting wxRibbonButtonBar events is a little bit counter-intuitive in WC.
Although you need to right-click on the button in the tree view and select "Connect Events" for each button, actually it is the button bar that has the event connected.
It doesn't matter what method you connect the first n buttons to, they all end up connected to the method set by the last button.
It is then necessary to use event.GetID() inside the method to get the ID of the clicked button (don't leave the buttons all as wxID_ANY )
I appreciate that this is because of the way in which the ribbon control handles button events, and the ID situation will be slightly improved in 2.9.5 with the GetButton() method.
I think it would be better to "connect" the event for the button bar object in the tree and the code that is generated connects all buttons within that bar.
Sorry if my explanation isn't clear or if I have misunderstood how this is meant to be used.
Although you need to right-click on the button in the tree view and select "Connect Events" for each button, actually it is the button bar that has the event connected.
It doesn't matter what method you connect the first n buttons to, they all end up connected to the method set by the last button.
It is then necessary to use event.GetID() inside the method to get the ID of the clicked button (don't leave the buttons all as wxID_ANY )
I appreciate that this is because of the way in which the ribbon control handles button events, and the ID situation will be slightly improved in 2.9.5 with the GetButton() method.
I think it would be better to "connect" the event for the button bar object in the tree and the code that is generated connects all buttons within that bar.
Sorry if my explanation isn't clear or if I have misunderstood how this is meant to be used.