필터 지우기
필터 지우기

Zoom in using mouse scroll during uiwait sometimes fails

조회 수: 3 (최근 30일)
Xingwang Yong
Xingwang Yong 2021년 12월 17일
댓글: Xingwang Yong 2021년 12월 17일
I want to zoom in a figure (with mouse scroll) during uiwait, however this did not always work.
If you directly run main.m, you'll find out you can not zoom in with mouse scroll.
However, if you comment test_zoomin(gcf), and run again, then move your mouse into figure, at last run test_zoomin(gcf) in command window, you'll find out you can zoom in with mouse scroll.
The above is well reproduced on my win10 with R2020a and R2021a. Also, I tried to use set(0, 'PointerLocation', ...) to programtically move mouse into figure before calling test_zoomin(), while it still did not work as intended.
Why zoom in with mouse scroll behaves so differently?
PS. Zoom in with the icon '+' on upper right of figure always work.
%% main.m
close all;
img = imread('pout.tif');
figure('Position',[1277 731 414 384]);imshow(img);
test_zoomin(gcf);
%% test_zoomin.m
function test_zoomin(h_fig)
if nargin < 1
h_fig = gcf;
end
figure(h_fig);
Button = uicontrol('Parent',h_fig,'Style','pushbutton','String',...
'OK','Units','normalized','Position',[0.95 0.90 0.05 0.05],'Visible','on',...
'Tag', 'OKPushbutton', 'Callback', @pushbtn_callback);
uiwait; % wait until user click 'OK'
end
function pushbtn_callback(src, event)
uiresume(); %Resume execution of blocked program
end

채택된 답변

yanqi liu
yanqi liu 2021년 12월 17일
may be the mouse zoom is default
%% main.m
close all; clc; clear all;
img = imread('pout.tif');
hfig=figure('Units','normalized','Position',[0.05 0.05 0.85 0.85]);
imshow(img);
ax = gca;
ax.Interactions = [zoomInteraction];
disableDefaultInteractivity(ax)
test_zoomin(hfig);
%% test_zoomin.m
function test_zoomin(h_fig)
if nargin < 1
h_fig = gcf;
end
figure(h_fig);
ax = gca;
ax.Interactions = [zoomInteraction];
enableDefaultInteractivity(ax)
Button = uicontrol('Parent',h_fig,'Style','pushbutton','String',...
'OK','Units','normalized','Position',[0.90 0.50 0.05 0.05],'Visible','on',...
'Tag', 'OKPushbutton', 'Callback', @pushbtn_callback);
uiwait; % wait until user click 'OK'
end
function pushbtn_callback(src, event)
uiresume(); %Resume execution of blocked program
end
  댓글 수: 1
Xingwang Yong
Xingwang Yong 2021년 12월 17일
It seems that uiwait changes default interactivity if the mouse did not move into figure at the beginning. Anyway, thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by