0

我的 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

但是我无法满足要求。请帮助我,任何解决方案都是可观的。

4

1 回答 1

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);
于 2013-03-15T19:53:26.203 回答