matlabuser-interfaceeeglab

WindowKeyPressFcn stops being called


I am working on some modifications to EEGlab's eegplot function (things like vim-style navigation etc.) that need to work through WindowKeyPressFcn.
However, the callback is not being called for some reason. I have been debugging the issue for some time and am a bit lost. I am looking for suggestions on what might be wrong. Unfortunatelly the eegplot function is big, complex and somewhat convoluted and I was unable to reproduce the issue in a simple example. Therefore I am looking for general suggestions on why a function handle that is clearly present in WindowKeyPressFcn might stop being used at some point.

Here is what I have learned so far:

So the function handle is 'healthy' so to speak, but for some reason it is not being used any more when a key is pressed and the figure has focus. When and why something like this could happen? Any ideas on things I should check to understand this issue?

Update:
I found out that WindowKeyPressFcn callback can sometimes be blocked by some window listeners, and tried out the following solution:

hManager = uigetmodemanager(gcf);
set(hManager.WindowListenerHandles,'Enable','off');

It doesn't work - WindowKeyPressFcn is still not called when I press a key. :(

Update 2:
Another thing that does not work:

chld = get(gcf, 'Children');
tp = get(chld, 'type');
chld = chld(strcmp(tp, 'uicontrol'));
set(chld, 'KeyPressFcn', @eegplot_readkey_new)

(eegplot_readkey_new is the function I use for reacting to keypresses)

Update 3:
And another one not working:

addlistener(gcf, 'WindowKeyPress', @eegplot_readkey_new);

Solution

  • Ok - I fiugred it out, although the solution is weird to say the least. For some mysterious reason using linesmoothing undocummented property prevents WindowKeyPressFcn from being called. I have absolutely no idea why...