Getting the default radio button value from a button group
显示 更早的评论
Hello!
I'm making a gui with multiple button groups that define values which is to be used in a function triggered by a push button.
My problem is that when I want the default radio button in the button group, I must "activate" it by pressing another button first, and then choosing it, else the value ends up empty.
Simplification of the code:
function indata2_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
function RUNpush_Callback(~, eventdata, handles)
St=get(handles.shiptype,'UserData');
%Send values into function
FunctionoutsideGUI(St)
%One of the button groups:
function shiptype_SelectionChangeFcn(hObject, eventdata, handles)
handles = guidata(hObject);
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'St1'
st=1;
case 'St2'
st=2;
end
set(handles.shiptype,'UserData',st);
guidata(hObject,handles)
Hope someone can help me, Im realy struggeling with this, and I want to get it rigth.
-Lina
回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!