how to get toggling effect in radio buttons?
Show older comments
This code creates 3 options for user but I want slight changes here.First by clicking option 1 it must display image in axes1. But after radio button is again toggled as if no choice is made that axes should not have same image it should be empty.
Sorry in figure I cant show the axes at right plane.
h = uibuttongroup('visible','off','Position',[0 0 .2 1]);
u0 = uicontrol('Style','Radio','String','Option 1',...
'pos',[10 350 100 30],'parent',h,'HandleVisibility','off');
u1 = uicontrol('Style','Radio','String','Option 2',...
'pos',[10 250 100 30],'parent',h,'HandleVisibility','off');
u2 = uicontrol('Style','Radio','String','Option 3',...
'pos',[10 150 100 30],'parent',h,'HandleVisibility','off');
set(h,'SelectionChangeFcn', 'disp selectionChanged');
set(h,'SelectedObject',[]); % No selection
set(h,'Visible','on');
5 Comments
Geoff Hayes
on 26 Apr 2015
preeti - please clarify what you mean by but after radio button is again toggled as if no choice is made that axes should not have same image it should be empty. Do you meant that if the user selects the radio button that has already been selected then the image should be cleared? You won't be able to capture the selection changed event because no selection will have changed (as you can't toggle the state of a single radio button).
preeti
on 27 Apr 2015
Jan
on 27 Apr 2015
This is not the standard behavior of radio buttons and this will confuse experineced computer users.
You have to implement the wanted behavior in the callback of the uibuttongroup. Did you try this already?
Michael Haderlein
on 27 Apr 2015
Also, what Jan meant (I think): Usually people use checkboxes for such purpose.
Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!