그림이 확대/축소 모드 일 때 WindowKeyPressFcn을 사용하고 싶습니다. 이 질문은 최근에 여기에 Overriding ctrl-z behavior in matlab zoom mode,하지만 난 그냥 같은 문제를 보여주기 위해 최소한의 예제를 만들었습니다 (나는 그들의 게시물에 대한 의견을 작성했을지만 아직 충분한 담당자가 없어). 아무도 우리가 누락 된 것을 압니까?MATLAB 확대 모드에서 키 누르기 듣기
function listenWhileZooming
%% Main problem:
% I want any key press to change the color of the plot, even when in Zoom
% mode. I tried to override the mode manager, but don't see any effect.
%%
%% Create and then hide the GUI as it is being constructed
f = figure('Visible','off','units','normalized','Position',[0.1 0.1 0.5 0.5],'windowkeypressfcn',@colorSwap);
%% Override mode manager
hManager = uigetmodemanager(f);
try
set(hManager.WindowListenerHandles, 'Enable', 'off'); % HG1
catch
[hManager.WindowListenerHandles.Enabled] = deal(false); % HG2
end
set(f, 'WindowKeyPressFcn',@colorSwap);
%% Plot something
plot(1,1,'bo')
%% Make the GUI visible
f.Visible = 'on';
%% Key press callback
function colorSwap(source,eventData)
myLine = findobj(source,'type','line');
if all(myLine.Color == [0 0 1])
plot(1,1,'ro')
else
plot(1,1,'bo')
end
end
end