UITableで選択した項目のインデックスの取得

UITableにn行1列の文字データの一覧を表示しています。
その中で選択した項目のインデックスを取得したいのですが、ご教示頂けませんでしょうか?
選択した値は下記のコードでapp.nameとして取得できています。
% Cell selection callback: UITable
function UITable_CellSelection(app, event)
indices = event.Indices;
app.name = app.UITable.Data{indices(1)};

 Accepted Answer

Atsushi Ueno
Atsushi Ueno on 31 Aug 2022

0 votes

indices = event.Indices;
event.Indicesが既に「実行中のアプリでユーザーが選択したセルの行および列のインデックスを含む n 行 2 列の配列」にアクセスしています。ローカル変数 indices ではなく、app.nameの様にオブジェクトのプロパティ値app.indicesに取り込めば「選択した項目のインデックスを取得」出来ます。
indices = % 最も左上のセルを選択した場合
1 1
indices = % 上から2番目のセルを選択した場合
2 1
indices = % ドラッグで複数セルを選択した場合
1 1
2 1

1 Comment

komfuyu
komfuyu on 1 Sep 2022
丁寧なご回答ありがとうございました。
無事インデックス取得できました。
indices(1)指定時点でインデックス取得していることを今理解できました。

Sign in to comment.

More Answers (0)

Categories

Find more on App Designer を使用したアプリ開発 in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 31 Aug 2022

Commented:

on 1 Sep 2022

Community Treasure Hunt

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

Start Hunting!