0

I have a gui that returns ,by pushing a button, an array of filenames. This array is shown in a figure at a table. I used that code:

f=figure('Position',[150 150 700 350]);
t=uitable('Parent',f,'Position' ,[25 25 700 200]);
set(t,'Data',handles.result_filenames');

This returns ,for example, 6 rows that each contain a filename in a specific folder.What i want is to find a way ,with which i provoke the animation of the file,from the table.I have the code-callback for the animation.

To sum up , i want ,for example push the name of a filename, or the number of the row of a filename ,or have something else in the table that calls the callback of the animation. Is it possible?Any ideas will be helpful.

So far , i used the below code:

f=figure('Position', [100, 200, 600, 460],...
'Name', 'Results-filenames',... % Title figure
'NumberTitle', 'off',... % Do not show figure number
'MenuBar', 'none'); % Hide standard menu bar menus


t=uitable('Parent',f,'Position' ,[50 100 300 230],...
    'Data',handles.result_filenames',...
    'ColumnWidth',{300},...
    'ColumnEditable', false,...
    'ToolTipString',...
    'Select cells to highlight them on the plot',...
    'ColumnName',{'filenames'},...
    'CellSelectionCallback','animate(variables)');

So, when i select a row(filename), the select_callback function does the animation of the filename(something that i must work) in another figure.

pap-00
  • 45
  • 3
  • 13

1 Answers1

2

You can add a button to start the animation:

tb = uitoolbar(f);
uipushtool(tb,'ClickedCallback',@yourFunction);

Alternatively set the 'CellSelectionCallback' to run the callback on selection - search for the tag and you will find a lot of examples how to do that.

Basically:

f = figure('Position',[150 150 700 350]);
t = uitable('Parent',f,'Position' ,[25 25 700 200]);
set(t,'Data',handles.result_filenames');

set(t,'CellSelectionCallback',@yourFunction);

Or make a fancy dropdown menu - so you can click the filename and choose between different options. Then you need the 'CellEditCallback'.

function fancyUitable
selector = { 'Start animation'; 'Go to folder' ; 'Call police' };

h = figure('Position',[200 100 268 120],'numbertitle','off','MenuBar','none');
defaultData =  repmat( {'select main option...'} );
columnformat = { {selector{:}} };
t = uitable(h,'Units','normalized','Position',[0 0 1 1],...
              'Data', defaultData,... 
              'ColumnFormat', columnformat,...  
              'CellEditCallback',@chooseOption);
end

function chooseOption(~,evt_edit)
%// evaluate callback and determine which option was chosen, call your function
end
Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
  • Thanks a lot for the answer, i will test what you sent and i will response for a feedback.I believe that i wll find what i want – pap-00 Jun 02 '14 at 15:22
  • 1
    Thanks a lot thewaywewalk, everything worked just fine.I may use ,in another edition,the fancyUitable funtion.Just great answer. – pap-00 Jun 05 '14 at 14:55