Issue with getrect and WindowKeyPressFcn
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!