2013-03-15 1211 views
0

我的GUI在單個搜索按鈕下有兩個複選框,即colourcheckTexturecheck。如果我點擊搜索按鈕,它應該檢查上面提到的兩種類型,並且應該運行相應的程序,並且如果兩個盒子都處於「MIN」位置,即沒有被檢查,則它應該給用戶一個消息,說明select type of searchMATLAB 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

從您問題中的描述中,您不希望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); 
+0

非常感謝。但是在colourcheck和Texturecheck_callback函數中寫什麼呢? – Chethan 2013-03-16 11:11:29

+0

您不需要在colourcheck和texturecheck回調中寫入任何內容。你用get(handles.Texturecheck,'Value')讀取它們的值並獲取(handles.colourCheck,'Value')。如果你喜歡答案,考慮接受它! :) – Molly 2013-03-16 14:45:59

+0

恩,謝謝:) – Chethan 2013-03-16 15:08:48