wxRibbon events with wxMDIChildFrame

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
benbrown
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Feb 23, 2017 11:36 am

wxRibbon events with wxMDIChildFrame

Post by benbrown »

Hello,

Does anyone have an example of how wxRibbon should be used with an MDI interface?

I have implemented in wxMDIParentFrame ok and events are passed to the parent event handler ok using an event table. However, some buttons are specific to the wxMDIChildFrame, and with the existing menu/toolbar interface I have these are captured in the child's event table. But for menu bars I explicity initialise the menu for each child:

Code: Select all

	subframe = new ChildFrame((wxMDIParentFrame*)m_parent, frame_name);

	subframe->SetMenuBar(((MainFrame*)m_parent)->InitMenuBar(frame_name));
I've tried both event table and connect() in the child but the events do not get caught.

Code: Select all

wxBEGIN_EVENT_TABLE(ChildFrame, wxMDIChildFrame)
	...
	EVT_MENU(MDI_EDIT_DIAGRAM, ChildFrame::OnEditDiagram)					/* Works OK for menu events */
	EVT_RIBBONBUTTONBAR_CLICKED(MDI_EDIT_DIAGRAM, ChildFrame::OnEditDiagramR)		/* Not caught on ribbon click */
	...
wxEND_EVENT_TABLE()

ChildFrame::ChildFrame(wxMDIParentFrame* parent, const wxString& title)
	: wxMDIChildFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxFULL_REPAINT_ON_RESIZE)
{
	...
	
	/* Doesn't work either */
	
	this->Connect(MDI_EDIT_DIAGRAM, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, wxRibbonButtonBarEventHandler(ChildFrame::OnEditDiagramR));

}
Many thanks.
Post Reply