Problem with drawline and drawpoint in 2021b
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Cris LaPierre
am 18 Okt. 2021
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?
Antworten (1)
Cris LaPierre
am 18 Okt. 2021
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 Kommentare
Cris LaPierre
am 19 Okt. 2021
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
Siehe auch
Kategorien
Mehr zu Visual Exploration 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!