keypress callback in figure works but always send a copy of key to matlab command line afterwards
조회 수: 2 (최근 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!