How to move a rectangle when a button is pressed in app designer?
2 次查看(过去 30 天)
显示 更早的评论
I created a rectangle in the UIAxes window by using
tArea = rectangle(app.UIAxes, 'Position', [25 25 50 50], 'FaceColor', [0 1 .75 .3], 'EdgeColor', [0 1 .75 .3]);
but now I want to change its position when I click a button in the app. I wanted to just use
tArea.Position = [25 30 50 50];
but I think tArea is outside the scope of the buttonClicked function. I am not sure the best way to make tArea visible to the other function in app designer. Or is there a better way to do it altogether?
0 个评论
采纳的回答
Ameer Hamza
2018-5-8
The easiest way is to create a public property in App designer. Go to Code View, in the top bar click the arrow under property and click Public Property. Name the property tArea and access it from any method using app.tArea. For example,
app.tArea = rectangle(app.UIAxes, 'Position', [25 25 50 50], 'FaceColor', [0 1 .75 .3], 'EdgeColor', [0 1 .75 .3]);
then to change
app.tArea.Position = [25 30 50 50];
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!