Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on June 20, 2012, 06:01:01 am

Title: CB SDK event handler question
Post by: ollydbg on June 20, 2012, 06:01:01 am
See: Code::Blocks SDK events - CodeBlocks (http://wiki.codeblocks.org/index.php?title=Code::Blocks_SDK_events)
and the change of rev 4234. I see that currently the "only" way to handle/register/subscribe a plugin's event handler is using Manager::RegisterEventSink method.

So, the traditionally Macro based (like EVT_EDITOR_CLOSE ) is useless, right?

Review the commit rev 4234, I see that the old Macro based way just plugin chains append the main app window. :)

Code in rev 4233.
Code
void PluginManager::NotifyPlugins(CodeBlocksEvent& event)
{
    if (Manager::IsAppShuttingDown())
        return;

    /* Things are simpler than before.
     * Just ask the last active plugin to process this event.
     * Because plugins are linked to the main app's event handler,
     * the event will travel up the chain normally.
     */
    if (s_LastKnownActivePlugin)
        s_LastKnownActivePlugin->ProcessEvent(event);
    else
        Manager::Get()->GetAppWindow()->ProcessEvent(event);
//    // notify plugins
//    for (unsigned int i = 0; i < m_Plugins.GetCount(); ++i)
//    {
//        cbPlugin* plug = m_Plugins[i]->plugin;
//        if (plug && plug->IsAttached())
//            plug->ProcessEvent(event);
//    }
//
//    // notify the app too
//    Manager::Get()->GetAppWindow()->ProcessEvent(event);
}