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.
Connecting wxRibbonButtonBar Events
-
- CodeLite Veteran
- Posts: 81
- Joined: Thu Mar 21, 2013 1:12 pm
- Genuine User: Yes
- IDE Question: c++
- Contact:
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Connecting wxRibbonButtonBar Events
The buttons don't have real class representing them, for visualization, I made it as if there is a real object behind it.iwbnwif wrote: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 )
At the end, a button is just a call to wxRibbonBarButton::AddButton
So yes, you must make sure that you don't use wxID_ANY
I had similar situation when I implemented wxToolBar, however, for wxToolBar I could allocate a wxToolBarItem which there is no equivalent in the wxRibbonBar family (at least in the released wx2.9.4)
The API suggests that this will change - once it will, I will probably adjust the event handling code
Eran
Make sure you have read the HOW TO POST thread