Select cell from UITable by mouse click and using a push button to execute a callback

30 visualizaciones (últimos 30 días)
Hi, I'm trying to create an app where I open several images from a folder and have them listed into a UITable (image filenames in x row: 1 column). I have already created this table and what I would like to do is select an image file from this list and use a push button to run my image processing algorithm in the UIAxes that I have created. I'm having trouble on how to create this callback and would love to hear a solotion to my problem, thanks. I am using r2020a by the way.

Respuesta aceptada

Mario Malic
Mario Malic el 15 de Oct. de 2020
Hi Raymond,
You need to create a CellSelection callback
Variable indices contains the index of selected row and column.
What might be a better way to process your image is to have the toggle button on/off, that will process your image if it's on, and do nothing if it's off.
% Cell selection callback: UITable
function UITableCellSelection(app, event)
indices = event.Indices;
if app.ToggleButton.Value
filepath = app.UITable.Data{indices(1),indices(2)} % Not sure if this is correct way
% of getting filepath, as it depends
% on type of data in the cell, so verify
processImage(app, filepath)
end
end
Otherwise, you could create a property that saves last selection and with the press of a button it would process file related to it.
% Cell selection callback: UITable
function UITableCellSelection(app, event)
app.Last_Selection = event.Indices;
end
% Button callback
ProcessImage(app) % Last_Selection is property of the app and doesn't need to be sent as an input arg

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by