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 ビュー (過去 30 日間)
古いコメントを表示
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
採用された回答
Walter Roberson
2018 年 7 月 17 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!