PS. I am building a GUI programatically, where I prefer that the toolbar is hidden and does not take up space - so, simply clicking the zoom tool icon instead, is an option I would like to avoid. Thank you.
Matlab R2017b looses focus from figure window, when using WindowKeyPressFcn to activate zoom function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christian Toft
el 17 de Jul. de 2018
Comentada: Christian Toft
el 17 de Jul. de 2018
In Matlab R2017b on Windows 10, calling the zoom function programatically, causes the figure window to loose focus, and keyboard input is directed to the Command Window from then on.
I did see this discussion, but it does not help, since I want to keep the WindowKeyPressFcn for the figure window: https://se.mathworks.com/matlabcentral/answers/385499-in-matlab-r2017a-how-do-i-change-the-focus-of-the-windowkeypressfcn-figure-callback-function-from
Any suggestions for how to work around this? Is the issue fixed in a newer version of Matlab?
See code example below. Thank you.
% Figure window focus is lost when calling 'zoom' command through keyboard
% shortcut 'z', and input is routed to command window.
% From here on, all keyboard input is useless and continues to route to
% command window.
function KeyPressZoomTest()
hFig = figure;
axes(hFig);
plot(1:10);
hFig.WindowKeyPressFcn = {@testKeyPressFcn};
end
function testKeyPressFcn(~,e)
switch e.Key
case 'z'
zoom;
end
end
Respuesta aceptada
Walter Roberson
el 17 de Jul. de 2018
This is still an issue through R2018a. I would tend to doubt it will change any time soon, but perhaps I will be surprised.
For work arounds, you need to consult undocumentedmatlab.com . The workaround that I documented only works up to R2014a, but Yair found a way for R2014b and later.
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!