News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Take over the event handler

Started by arthurzmj, May 07, 2014, 05:16:38 PM

Previous topic - Next topic

arthurzmj

Hello guys,

I'm developing a vim-like key shortcut plugin for C::B.
I want to take over the control of the editor, so I created a wxEvtHandler and use window.PushEventHandler() to add my handler to the top of the handler chain.
But when I press CTRL+A or CTRL+F or some other key shortcuts that I configured in "keybinder", the standard key shortcut plugin in C::B, the handler I pushed can not receive the event.
I guess the event handler of "keybinder" is above my handler in the handler chain which may mean the initialization of "keybinder" is later than my plugin because if I disable the "keybinder", my plugin can work well.

Does someone have suggestion for my problem?

stahta01

#1
I suggest reading this thread it might have answers.
I really do NOT know enough C++ to judge if it has answers; so, I did NOT read the thread.

http://forums.next.codeblocks.org/index.php?topic=6214.10

Edit: I saw that you posted in that thread, sorry about the noise.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Alpha

Catching key events globally might be helpful (I have not looked in depth though).

Pecan

Keybinder loads the key definitions after all plugins have finished initializing, This is in order to catch key defs defined by plugins.

Keybinder binds it's event handler to each created editor at the create window event. It catches a defined key and passes it on to a menu event.

What editor event did you bind CTRL+A and CTRL+F to? Did you define command events to catch the menu events?

See: cbkeybinder.cpp line 955
// ----------------------------------------------------------------------------
void cbKeyBinder::OnWindowCreateEvent(wxEvent& event)
// ----------------------------------------------------------------------------
{...

keybinder.cpp 1223
// ----------------------------------------------------------------------------
//  wxKeyBinder Attach
// ----------------------------------------------------------------------------
void wxKeyBinder::Attach(wxWindow *p)
{..



arthurzmj

Quote from: Pecan on May 07, 2014, 08:04:35 PM
Keybinder loads the key definitions after all plugins have finished initializing, This is in order to catch key defs defined by plugins.

Keybinder binds it's event handler to each created editor at the create window event. It catches a defined key and passes it on to a menu event.

What editor event did you bind CTRL+A and CTRL+F to? Did you define command events to catch the menu events?

See: cbkeybinder.cpp line 955
// ----------------------------------------------------------------------------
void cbKeyBinder::OnWindowCreateEvent(wxEvent& event)
// ----------------------------------------------------------------------------
{...

keybinder.cpp 1223
// ----------------------------------------------------------------------------
//  wxKeyBinder Attach
// ----------------------------------------------------------------------------
void wxKeyBinder::Attach(wxWindow *p)
{..




I bind CTRL+A to EVT_KEY_PRESS.
Did you mean I need to define some menu items and set the key shortcuts via keybinder? But in fact these key shortcuts are not menu events.
I think maybe I can provide a script to append a new profile to keybinder configuration file. I found the file and had a look at it. I wonder whether I can copy the default profile and delete the key shortcuts I used. Is it protable? I mean with the version of C::B changing, do I need to change my script in this way?

arthurzmj

Quote from: Alpha on May 07, 2014, 07:50:47 PM
Catching key events globally might be helpful (I have not looked in depth though).

Thanks. But it can not cancel the default action of the key shortcuts, is it?