Strange Behaviour of WindowsKeyPressedFcn and ButtonDownFcn on Mac

1 Ansicht (letzte 30 Tage)
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)

Akzeptierte Antwort

Jiawen Liu
Jiawen Liu am 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:
  1 Kommentar
Elco Bakker
Elco Bakker am 14 Nov. 2017
Bearbeitet: Elco Bakker am 14 Nov. 2017
Dear Jiawen,
Thank you for taking a look; I guess it's just my system and I will try a fresh install.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by