Allow user to draw a line using mouse

34 次查看(过去 30 天)
How can I get a user to draw a line using their mouse in an App Designer app using R2019a?
Edit: If App Designer does not support it, will GUIDE?
Thanks in advance.

采纳的回答

Adam Danz
Adam Danz 2019-11-14
编辑:Adam Danz 2019-11-14
If you have the image processing toolbox, use drawline(). Something will have to trigger the function such as a button press or context menu selection. The example below responds to a button press which will then allow the user to click-and-drag a single line on an existing UIAxes.
function ButtonPushed(app, event)
hold(app.UIAxes, 'on')
drawline(app.UIAxes)
% ^^^^^^^^^^ your ui axis handle
end
  16 个评论
John D
John D 2019-11-16
编辑:John D 2019-11-16
I have tried it again in a new app, and have now got it to work in GUIDE.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
drawline(handles.axes1);
Adam Danz
Adam Danz 2019-11-16
Ok, good! If you start using a more recent release you could implement it in app designer, too (r2019b or later).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by