Strange Behaviour of WindowsKeyPressedFcn and ButtonDownFcn on Mac
1 view (last 30 days)
Show older comments
This is a simple example of my problem:
f = figure;
f.ButtonDownFcn = @(src,event) fprintf('clicked\n');
f.WindowKeyPressFcn = @(src,event) fprintf('pressed %s \n',event.Key);
f.WindowKeyReleaseFcn = @(src,event) fprintf('released %s \n',event.Key);
if I hold down 'o' and click on the figure, they key press function seems to die (i.e. no longer activates) though the key release function and button down function still do. If I then hold down 'j' and double click on the figure, the key press function come back to life.
MATLAB 2015b MacOS 10.12.6 (16G29)
0 Comments
Accepted Answer
Jiawen Liu
on 9 Nov 2017
Hi Elco,
I understand that you are facing an issue with using the "WindowKeyPressFcn" on Mac machine after holding down the key and clicking on the figure. I tried both the script you posted in the question and my own script, but I was not able to reproduce the issue on my system.
There is one fact worth noticing that the "WindowKeyPressFcn" callback executes whenever a key press occurs while the figure(or any of its childern) has focus.
If the issue still persists, please try to use an alternative callback function "KeyPressFcn" which could implement the similar functionality.
Please refer to the following link for more details:
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!