Problem with drawline and drawpoint in 2021b
8 次查看(过去 30 天)
显示 更早的评论
Hi,
I created an app in matlab 2020b an now opened it in 2021b. In the app I can draw multiple lines and points over an image in UIaxes and then stop the drawline/drawpoint function by pressing a button in the app. This worked fine in 2020b but now in 2021b when I press the button at the end it draws a point/line at the edge of the axes and I cant use the button. If you need more information, just tell me.
I hope you can help me.
function DrawLinesButtonValueChanged(app, event)
import java.awt.Robot;
import java.awt.event.*;
value = app.DrawLinesButton.Value;
if value==1
userstop=false;
while ~userstop
d=drawline(app.UIAxes,"color",[0,1,0],"tag","anglelines");
if ~isvalid(d) || isempty(d.Position)
userstop=true;
else
pos = d.Position;
diffPos = diff(pos);
length = hypot(diffPos(1),diffPos(2));
end
end
if value==0
SimKey=Robot;
SimKey.keyPress(java.awt.event.KeyEvent.VK_ESCAPE);
SimKey.keyRelease(java.awt.event.KeyEvent.VK_ESCAPE);
end
end
This is the code I use in the callback of a state button. Im drawing the lines in UIAxes.
6 个评论
Cris LaPierre
2021-10-18
I am able to replicate an issue where, when toggling the state, a point is drawn the edge of my UIAxes closest to the button. However, the button is still usable. Is that what you are seeing?
回答(1 个)
Cris LaPierre
2021-10-18
What is happening is that drawline is registering the click on the canvas (i.e. it is not limiting clicks to when the cursor is over the axes). This is true for both axes and uiaxes, and figure and uifigures, both in MATLAB and in App Designer.
Because you call drawline inside a while loop, it is always actively waiting for the next click. You need to cancel your drawline operation before clicking on the button. You can do this by pressing the escape key.
2 个评论
Cris LaPierre
2021-10-19
I see your point. I don't know there is anything you can do to change this behavior. If you feel this change has an adverse impact, the best thing to do is report it here: https://www.mathworks.com/support/contact_us.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!