2013-03-15 1 views
0

내 GUI에는 단일 검색 버튼 아래에 colourcheckTexturecheck의 두 개의 확인란이 있습니다. 검색 버튼을 클릭하면 위에서 언급 한 두 가지 유형을 모두 확인해야하며 각 프로그램이 실행되어야합니다. 두 상자가 모두 'MIN'위치에있는 경우 즉, 체크하지 않은 경우 사용자에게 select type of search이라는 메시지를 보내야합니다.MATLAB GUI의 확인란 상자

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 

그러나 요구 사항을 충족 할 수 없습니다. 제발 나를 도울 수있는 해결책이 있습니다.

답변

1

colourcheck_Callback을 클릭하면 Search_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); 
+0

고맙습니다. 그러나 colourcheck & Texturecheck_callback functoins에 무엇을 써야할까요? – Chethan

+0

colourcheck 및 texturecheck 콜백에 아무 것도 쓰지 않아도됩니다. get (handles.Texturecheck, 'Value') 및 get (handles.colourCheck, 'Value')을 사용하여 값을 읽습니다. 당신이 대답을 좋아한다면, 그것을 받아들이는 것을 고려하십시오! :) – Molly

+0

그럼 고마워요 :) – Chethan

관련 문제