Reseting Controls in Matlab GUI

I am trying to create functionality in my code where I am able to reset certain aspects of my GUI. I have created a reset function but it only works when when I select "Reset" in my menuItemReset function. It does not work when I call my reset function for on of my radioSpacial function. Any ideas as to why this is happening?
% --- Executes on button press in radioSpacial.
function radioSpacial_Callback(hObject, eventdata, handles)
% hObject handle to radioSpacial (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radioSpacial
if get(hObject,'Value') == 1
Reset;
end
% --------------------------------------------------------------------
function menuItemReset_Callback(hObject, eventdata, handles)
% hObject handle to menuItemReset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Reset;
return;
function Reset
global ResetSet; % Flag to see if reset has taken place
global Thresh; % Threshold value... MAY NOT NEED
global ThreshLock; % MAY NOT NEED
global Norm; % Normalization flag... MAY NOT NEED
global AutoThresh; % Auto-thresholding flag
global ImageLoaded; % Image loaded flag
ResetSet = 1;
Thresh = 0.5;
ThreshLock = 0;
Norm = 0;
AutoThresh = 1;
global hAxesImage1;
global hAxesImage2;
global hAxesImage3;
global hAxesImage4;
% Initialzie all the axes, if not done so
if(isempty(hAxesImage1))
hAxesImage1 = findobj(gcf, 'Tag', 'axes1');
end
if(isempty(hAxesImage2))
hAxesImage2 = findobj(gcf, 'Tag', 'axes2');
end
if(isempty(hAxesImage3))
hAxesImage3 = findobj(gcf, 'Tag', 'axes3');
end
if(isempty(hAxesImage4))
hAxesImage4 = findobj(gcf, 'Tag', 'axes4');
end
% Find the objects that need to be reset
hRadioSpacial = findobj(gcf,'Tag','radioSpacial');
hRadioFrequency = findobj(gcf,'Tag','radioFrequency');
hRadioNO = findobj(gcf,'Tag','radioNo');
hRadioYES = findobj(gcf,'Tag','radioYes');
hEditLow = findobj(gcf,'Tag', 'editLow');
hEditHigh = findobj(gcf,'Tag','editHigh');
hEditBand = findobj(gcf,'Tag','editBand');
hEditAverage = findobj(gcf,'Tag','editAverage');
hEditBoost = findobj(gcf,'Tag','editBoost');
hEditMedian = findobj(gcf,'Tag','editMedian');
% Reset the objects
set(hRadioSpacial,'Enable','off');
set(hRadioFrequency,'Enable','off');
set(hRadioNO,'Enable','off');
set(hRadioYES,'Enable','off');
set(hEditLow,'Enable','off');
set(hEditHigh,'Enable','off');
set(hEditBand,'Enable','off');
set(hEditAverage,'Enable','off');
set(hEditBoost,'Enable','off');
set(hEditMedian,'Enable','off');
if ImageLoaded
filterInit;
end
return;

1 commentaire

Walter Roberson
Walter Roberson le 17 Nov 2013
When you say that it does not work, what happens instead?
Is Reset being called in that case? If you put a disp() in it, does it get called?
Perhaps you could disp(get(hObject,'Value')) in the Radiospacial callback to be sure the Value is what you think it should be.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Question posée :

le 17 Nov 2013

Commenté :

le 17 Nov 2013

Community Treasure Hunt

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

Start Hunting!

Translated by