我的GUI在一个搜索按钮下方有两个复选框,即colourcheck
和Texturecheck
。如果我点击搜索按钮,它应该检查上面提到的两种类型并且应该运行相应的程序,如果两个盒子都处于“MIN”位置,即未检查它应该向用户说明select type of search
。
我已经剪切了search_callback程序。
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
但是我无法满足要求。请帮助我,任何解决方案都很明显。
答案 0 :(得分:1)
根据您问题中的说明,您不希望在点击Search_Callback
时调用colourcheck_Callback
。相反,您希望在单击搜索按钮时根据选中的复选框执行其他操作。您可以使用以下回调作为搜索按钮:
% --- 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);