Issue with getrect and WindowKeyPressFcn
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!