Issue with getrect and WindowKeyPressFcn

16 views (last 30 days)
Uday
Uday on 26 Aug 2017
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

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!