nav-left cat-right
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;
end
lastValue = get(hObject,'Value');

Einen Kommentar schreiben

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


*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP-SpamFree by Pole Position Marketing