nav-left cat-right
Matthias Pospiech > Programming > matlab > check if gui selection has changed

check if gui selection has changed

The callback of an ui element is called whenever the element has been modified. However this does not necessarily mean that the value of the element has changed.

Here is an example where an action is only performed if the value has changed. The trick is to use a value variable with persistent.

function popupmenuAlgorithm_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuAlgorithm (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
persistent lastValue;
if (lastValue ~= get(hObject,'Value'))
    handles.('status').('doCalibrationUpdate') = true;
lastValue = get(hObject,'Value');

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *


This blog is kept spam free by WP-SpamFree.