keypress callback in figure works but always send a copy of key to matlab command line afterwards
5 ビュー (過去 30 日間)
古いコメントを表示
Hi,I am writing a callback to a figure:
f=figure;
imagesc(rand(56,67))
% set(f,'KeyPressFcn',[]);
set(f,'WindowKeyPressFcn',@(Obj,EventData)loomFigureCallback(Obj,EventData,f))
function loomFigureCallback(Obj,EventData,f)
figure(f);
if uint8(EventData.Character)==27
a = zoom;a.enable = 'off';
pan off
elseif strcmpi(EventData.Character,'M') % Esc button
a = zoom;a.enable = 'on';
elseif strcmpi(EventData.Character,'P')
pan on
elseif strcmpi(EventData.Character,'X')
zoom xon
elseif strcmpi(EventData.Character,'Y')
zoom yon
elseif strcmpi(EventData.Character,'Z')
zoom on
end
end
When the figure toogle bar button is not selected, the key callback works well (e.g., press P will make the pan button selected, and then callback is ignored untill exited by hand-click on pan button to exit).
The problem is that when I press any button, the key was also typed immediately into the command line and make the matlab main panel active, no matter the key has callback or not.
Is there a way to let matlab not acquire focus when pressing a key?
Thanks.
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!