Set a selection of a uibutton group element (Changing users choice)

  • Follow


Hi folks!

How can I code a selction a uibuttongroup element?  Below I have pasted the SelectionChangeFunction as constructed by GUIDE. Within this function, I would like to change the users choice under certain circumstances.

The propper comand might be:   
                        set(hObject,'SelectedObject',h);

 but I have no idea how access h. I tried:   
                      h = findobj(hObject,'Tag','No_Preselection');

Do I miss anything?

Many thanks in advance,

LS

% --- Executes when selected object is changed in File_Preselection.
function File_Preselection_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in File_Preselection
% eventdata  structure with the following fields (see UIBUTTONGROUP)
%	EventName: string 'SelectionChanged' (read only)
%	OldValue: handle of the previously selected object or empty if none was selected
%	NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

switch get(eventdata.NewValue,'Tag') % Get tag of selected object
    
    case 'No_Preselection'
        
        % do something
        
    case  'Use_Preselection'

        File = uipickfiles('REFilter','.mat$','num',1, 'out','char');
        if File == 0 % no file was selected
            
            % change the choosen button to CASE 'No_Preselection'
            h = findobj(hObject,'Tag','No_Preselection');
            set(hObject,'SelectedObject',h);
            
        else
            % do something
        end

    case  'Save_Preselection'

        % do something different
end
0
Reply Lukas 8/13/2010 11:15:21 PM

It was trivail...

set(handles.No_Preselection,'Value',1)

solves the problem....

LS
0
Reply Lukas 8/14/2010 5:54:04 AM


Alternatively:

 set(handles.File_Preselection,'SelectedObject',  handles.No_Preselection);


....
0
Reply Lukas 8/14/2010 6:23:05 AM

2 Replies
335 Views

(page loaded in 0.015 seconds)

Similiar Articles:













7/25/2012 11:00:26 PM


Reply: