Reputation: 43
My GUI has two checkboxes, namely colourcheck
and Texturecheck
, below a single search button. If I click on the search button, it should check for both types mentioned above and respective program should run, also if both box are in 'MIN' position i.e., not checked it should give a message to user stating select type of search
.
I've clipped search_callback program.
function Search_Callback(hObject, eventdata, handles)
% hObject handle to Search (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data
% --- Executes on button press in colourcheck.
function colourcheck_Callback(hObject, eventdata, handles)
% hObject handle to colourcheck (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data
% Hint: get(hObject,'Value') returns toggle state of colourcheck
if (get(hObject,'Value') == get(hObject,'Max'))
Search_Callback(hObject, eventdata, handles)
else
% Checkbox is not checked-take approriate action
end
However I am not able to meet the requirements. Please help me, any solution is appreciable.
Upvotes: 0
Views: 8178
Reputation: 13610
From the description in your question, you don't want Search_Callback
called when you click colourcheck_Callback
. Instead you want some other action taken when the search button is clicked based on which check boxes are selected. You could use a callback like the following for your search button:
% --- Executes on button press in search.
function search_Callback(hObject, eventdata, handles)
% hObject handle to search (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
isTexture = get(handles.Texturecheck,'Value');
isColour = get(handles.colourCheck,'Value');
if and(isTexture, isColour)
'do something'
elseif isColour
'do something else'
elseif isTexture
'do something else'
else
'warn user'
end
guidata(hObject, handles);
Upvotes: 1