Matrix of buttons in AppDesigner
3 ビュー (過去 30 日間)
古いコメントを表示
I would like to have a matriz of buttons where I can use all of this buttons. I tried someting like this (first print), but it doesn't work because I can use . in this type of variables.
I tried other option, which is in the second foto. This works and do what I want. It creates a matrix of buttons. But then, in other functions, I want to disable all of the buttons and I can't do it because I can't use an array, like in the first foto. Is there a way to use an array of buttons like in my first foto?
One example is my third foto. I want to disable all of the buttons in a for cicle, but it doesn't work because I can't use the array. In my code, if my matrix was 3x3, it only disable the last button (last image).
I wish I explain well what is my problem.
0 件のコメント
採用された回答
Cris LaPierre
2021 年 11 月 15 日
First, see this answer. The summary is it is often better to arrange everything on the canvas ahead of time, and then change the visibility of the components as needed rather than trying to do it dynamically.
As for your particular issue, you need to keep the datatype a structure in order to preserve the object handle. When you use array indexing, you loose that. A workaround is to split i and j over two different fields. This is an adaptation of what you shared.
% Value changed function: CheckBox
function CheckBoxValueChanged(app, event)
m=1;
n=2;
a=10;
b=350;
for i = 1:m
for j=1:n
app.buttonsArray(i).button(j) = uibutton(app.UIFigure,'push');
app.buttonsArray(i).button(j).Position = [a+(j-1)*60 b-(i-1)*60 55 55];
app.buttonsArray(i).button(j).Text = sprintf("Antenna\n%d, %d",i,j);
end
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!