フィルターのクリア

App Designer-Tag in event is empty; Value of Listbox is not order

4 ビュー (過去 30 日間)
Chong Cao
Chong Cao 2017 年 3 月 31 日
コメント済み: Chong Cao 2018 年 9 月 6 日
First quesiton is that, I found the 'event' parameter which is the input of callbacks, is containing lots of Object's information, but the 'event.Source.Tag' is empty all the time. If so, how can Callback get the current Object I operate? I know in GUI, every Callback has the input parameter 'hObject' to use, that's convinent. What should I do in App Designer?
Second question is that, in App Designer, the 'Value' of Listbox is not same as in GUI. In GUI,it's an order number of selected item. However in AD, it's item itself (or itemdata itself).If I want to get order number, I have to make itemdata become order series 1,2,3... I think it's not a satisfying method. Then, what should I do? (I need this order number because that in my app every item is corresponding to a matrix. For example, item1 - matrix(:,:,1), item2 - matrix(:,:,2)... When I select an item, the corresponding matrix should be displayed in app. So, the order of selected item need to be acquired).
  2 件のコメント
Adam
Adam 2017 年 3 月 31 日
編集済み: Adam 2017 年 3 月 31 日
Do your objects have a tag (in the actual GUI layout, I mean, not in the callback)?
Chong Cao
Chong Cao 2017 年 3 月 31 日
In GUI, I surely knows what tag is. But I'm not sure this 'Tag' in AD means what. Is 'edit' the tag of 'app.edit' in AD? If so, every object must have a tag I think.

サインインしてコメントする。

回答 (1 件)

Jurgens Wolfaardt
Jurgens Wolfaardt 2018 年 9 月 5 日
編集済み: Jurgens Wolfaardt 2018 年 9 月 5 日
For first question: Pre-assign a descriptive Tag to each your objects (in a startupFcn) with the following code:
FieldNames = fieldnames(app);
for i = 1:length(FieldNames)
app.(FieldNames{i}).Tag = FieldNames{i};
end
Now use strcmp (or similar) to compare the object's event.Source.Tag to determine the function that called it.
Second question answered here: https://au.mathworks.com/matlabcentral/answers/415730-app-designer-listbox-and-dropdown-selection-number#answer_333978
  1 件のコメント
Chong Cao
Chong Cao 2018 年 9 月 6 日
Great!I've found a method,but your method is much more convenient to tag all field. Thanks. For these 1.5 years, I've got a lot progress and write some big apps for my engineering work. I have to say, writting apps is lonely, almost every signle problem needs to be study, and hundreds of them are coming over to me with no ends……

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by