Changeset 379 for trunk/src/read_GUI.m


Ignore:
Timestamp:
Jan 27, 2012, 1:59:18 AM (13 years ago)
Author:
sommeria
Message:

several bugs corrected
set_object.fig rationalized so that read_set_object is replaced by the rgeneral fct read_GUI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_GUI.m

    r363 r379  
    55struct=[];%default
    66hchild=get(handle,'children');
     7hchild=flipdim(hchild,1);% reverse the order to respect the tab order in the GUI
    78for ichild=1:numel(hchild)
    89    if strcmp(get(hchild(ichild),'Visible'),'on')
     
    1516                object_style=get(hchild(ichild),'Style');
    1617                check_input=1;%default
     18                index=0;
    1719                switch object_style
    1820                    case {'checkbox','radiobutton','togglebutton'}
    1921                        input=get(hchild(ichild),'Value');
    2022                    case 'edit'
    21                         separator=regexp(tag,'^num_');
     23                        separator=regexp(tag,'^num_','once');%look for the prefix 'num_'
    2224                        if isempty(separator)
    2325                            input=get(hchild(ichild),'String');
    24                         else
    25                             input=str2double(get(hchild(ichild),'String'));
     26                        else  %transform into numeric if the edit box begins by the prefix 'num_'                                           
     27                            input=str2double(get(hchild(ichild),'String'));                       
    2628                            tag=regexprep(tag,'^num_','');
     29                            % detect tag name ending by an index: then interpret the input as array(index)
     30                            r=regexp(tag,'_(?<index>\d+)$','names');% detect tag name ending by an index
     31                            if ~isempty(r)
     32                                tag=regexprep(tag,['_' r.index '$'],'');
     33                                index=str2double(r.index);
     34                            end
    2735                            %deal with undefined input: retrieve the default value stored as UserData
    2836                            if isnan(input)
     
    3947                            check_input=0;
    4048                        end
    41                         separator=regexp(tag,'^num_');
     49                        separator=regexp(tag,'^num_','once');
    4250                        if ~isempty(separator)
    4351                            input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_'
     
    4856                end
    4957                if check_input
    50                     struct.(tag)=input;
     58                    if index==0
     59                       struct.(tag)=input;
     60                    else
     61                       struct.(tag)(index)=input;
     62                    end
    5163                end
    5264            case 'uitable'
Note: See TracChangeset for help on using the changeset viewer.