Issue with getrect and WindowKeyPressFcn
조회 수: 16 (최근 30일)
이전 댓글 표시
Hi, I have a code which displays an image and allows user to draw rectangles using getrect function in an infinite loop. I also want to set the title of the figure interactively using key press. But getrect is blocking keyboard events and is not allowing WindowKeyPressFcn callback to execute. Any suggestions on how to enable keyboard events during getrect.
figure('WindowKeyPressFcn',@keypress_fun)
hold on
imshow('peppers.png')
title('a')
while(1)
rect=getrect();
bbxmin=floor(rect(1));
bbymin=floor(rect(2));
bbwidth=floor(rect(3));
bbheight=floor(rect(4));
rectangle('Position', [bbxmin, bbymin, bbwidth, bbheight],'EdgeColor','g', 'LineWidth', 2)
end
function keypress_fun(src,eventdata)
title(eventdata.Key)
end
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!