Greetings all,
I've been meaning to try and experiment a bit with extending code::blocks, adding some features to the editor window. Ultimately, if all goes well, i'd like to contribute to the code completion plugin, or create an alternative one with some features such as Netbeans code completion/refactoring features.
I'd like, firstly, to be able to detect when the Control key was pressed while the user is inside the editor, but haven't been able to figure out how.
I've been looking at the code and wiki, but it's not clear how to do this.
What i have so far:
- created a Generic Plugin using the New...Project...CodeBlocks plugin wizard
- added the table event declaration on the .h file with DECLARE_EVENT_TABLE() and associated the event with my callback function (as per wxWidget documentation, and following the byogame plugin code, as it was the only place i could find some keyboard event handling)
BEGIN_EVENT_TABLE(keys,cbPlugin)
EVT_KEY_UP(keys::OnKeyUp)
END_EVENT_TABLE()
like so:
keys.h
#ifndef KEYS_H_INCLUDED
#define KEYS_H_INCLUDED
// For compilers that support precompilation, includes <wx/wx.h>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <cbplugin.h> // for "class cbPlugin"
class wxKeyEvent;
class keys : public cbPlugin
{
public:
keys();
virtual ~keys();
virtual void BuildMenu(wxMenuBar* menuBar){}
virtual void BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data = 0){}
virtual bool BuildToolBar(wxToolBar* toolBar){ return false; }
protected:
virtual void OnAttach();
virtual void OnRelease(bool appShutDown);
private:
void OnKeyUp(wxKeyEvent& event);
DECLARE_EVENT_TABLE()
};
#endif // KEYS_H_INCLUDED
keys.cpp
#include <sdk.h> // Code::Blocks SDK
#include <configurationpanel.h>
#include "keys.h"
namespace
{
PluginRegistrant<keys> reg(_T("keys"));
}
BEGIN_EVENT_TABLE(keys,cbPlugin)
EVT_KEY_UP(keys::OnKeyUp)
END_EVENT_TABLE()
// constructor
keys::keys()
{
if(!Manager::LoadResource(_T("keys.zip")))
{
NotifyMissingFile(_T("keys.zip"));
}
}
// destructor
keys::~keys()
{
}
void keys::OnAttach()
{
}
void keys::OnRelease(bool appShutDown)
{
}
void keys::OnKeyUp(wxKeyEvent& event)
{
if( !IsAttached() )
return;
Manager::Get()->GetLogManager()->Log( _("key up") );
}
I expected the releasing of any key to print to the Log Manager, but nothing so far.
Care to help?