Commit 2647fdfd authored by Maciej Suminski's avatar Maciej Suminski

Fixed context submenus event handlers (GAL/Windows).

parent 5447bb59
......@@ -114,8 +114,8 @@ CONTEXT_MENU& CONTEXT_MENU::operator=( const CONTEXT_MENU& aMenu )
void CONTEXT_MENU::setupEvents()
{
Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
}
......@@ -194,7 +194,7 @@ void CONTEXT_MENU::Clear()
}
void CONTEXT_MENU::onMenuEvent( wxEvent& aEvent )
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
{
OPT_TOOL_EVENT evt;
......@@ -219,7 +219,25 @@ void CONTEXT_MENU::onMenuEvent( wxEvent& aEvent )
}
else
{
// Under Linux, every submenu can have a separate event handler, under
// Windows all submenus are handled by the main menu.
#ifdef __WINDOWS__
if( !evt ) {
// Try to find the submenu which holds the selected item
wxMenu*menu = NULL;
FindItem( m_selected, &menu );
if( menu )
{
menu->ProcessEvent( aEvent );
return;
}
assert( false ); // The event should be handled above
}
#else
evt = m_customHandler( aEvent );
#endif /* else __WINDOWS__ */
// Handling non-action menu entries (e.g. items in clarification list)
if( !evt )
......
......@@ -95,12 +95,12 @@ public:
}
protected:
void setCustomEventHandler( boost::function<OPT_TOOL_EVENT(const wxEvent&)> aHandler )
void setCustomEventHandler( boost::function<OPT_TOOL_EVENT(const wxMenuEvent&)> aHandler )
{
m_customHandler = aHandler;
}
virtual OPT_TOOL_EVENT handleCustomEvent( const wxEvent& aEvent )
virtual OPT_TOOL_EVENT handleCustomEvent( const wxMenuEvent& aEvent )
{
return OPT_TOOL_EVENT();
}
......@@ -116,7 +116,7 @@ private:
void setupEvents();
///> Event handler.
void onMenuEvent( wxEvent& aEvent );
void onMenuEvent( wxMenuEvent& aEvent );
/**
* Function setTool()
......@@ -144,7 +144,7 @@ private:
std::map<int, const TOOL_ACTION*> m_toolActions;
/// Custom events handler, allows to translate wxEvents to TOOL_EVENTs.
boost::function<OPT_TOOL_EVENT(const wxEvent& aEvent)> m_customHandler;
boost::function<OPT_TOOL_EVENT(const wxMenuEvent& aEvent)> m_customHandler;
friend class TOOL_INTERACTIVE;
};
......
......@@ -152,7 +152,7 @@ public:
}
protected:
OPT_TOOL_EVENT handleCustomEvent( const wxEvent& aEvent )
OPT_TOOL_EVENT handleCustomEvent( const wxMenuEvent& aEvent )
{
#if ID_POPUP_PCB_SELECT_VIASIZE1 < ID_POPUP_PCB_SELECT_WIDTH1
#error You have changed event ids order, it breaks code. Check the source code for more details.
......@@ -183,7 +183,7 @@ protected:
bds.SetTrackWidthIndex( 0 );
}
else if( id > ID_POPUP_PCB_SELECT_VIASIZE1 ) // via size has changed
else if( id >= ID_POPUP_PCB_SELECT_VIASIZE1 ) // via size has changed
{
assert( id < ID_POPUP_PCB_SELECT_WIDTH_END_RANGE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment