フィルターのクリア

Switching a radio button back to last value

2 ビュー (過去 30 日間)
Sam Gottheim
Sam Gottheim 2017 年 9 月 12 日
コメント済み: Sam Gottheim 2017 年 9 月 13 日
Hi,
I'd like my radiobutton to switch back to the last used value if the user of the gui answers 'no' to the dialogbox.
Here is the button/function (I have three buttons/cases in the actual code)
%buttons
FileTypeBG = uibuttongroup(ParametersFig, 'Visible','on',...
'Title','Fit Type',...
'Parent',ParametersFig,'units','normalized','outerposition',[.22 .33 .10 .12],...
'BackgroundColor',.8*[1 1 1],...
'SelectionChangedFcn',@FileType);
Filenames_B = uicontrol(FileTypeBG,'Style',...
'radiobutton',...
'String','Filenames',...
'Position',[10 3 100 30],...
'BackgroundColor',.8*[1 1 1],...
'HandleVisibility','on');
end
function FileType(src, event)
switch src.String
case 'Filenames'
FileMethod.Tag = Filenames
choice = questdlg('Are you sure?',...
'Switching to Process Data via Filenames Confirmation',...
'Yes','No','No');
switch choice
case 'Yes'
Update1
otherwise
???????????????
end
end
end

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 12 日
oldv = event.OldValue;
if ~isempty(oldv)
oldv.Value = 1; %activate previous button
else
event.NewValue.Value = 0; %no previous button, just deactivate current one
end
  1 件のコメント
Sam Gottheim
Sam Gottheim 2017 年 9 月 13 日
I like this answer and it is probably more general and safe, but since my buttongroup always starts with one of the values selected, just using this seems to work
oldv = event.OldValue;
oldv.Value = 1;

サインインしてコメントする。

その他の回答 (1 件)

Rik
Rik 2017 年 9 月 12 日
Just save the previous state to the guidata struct. You can easily load it like this:
hObject=get(scr,'Parent');
handles=guidata(hObject);

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by