www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@itemList/incrementSelection.m
function incrementSelection(obj) %INCREMENTSELECTION Move selection down the list % % INCREMENTSELECTION(OBJ) moves the selection to the next one in the list % as it is currently displayed on screen. When the selection reaches the % end of the list it wraps to the beginning again. If the selection is % initially empty, the top item is selected. If there are multiple items % initially selected, the item after the first selection will become % selected. % % Note that the selection is moved down the list as it appears on screen, % which may not be the same order as the list of items given to the object. % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. if ~isempty(obj.Items) idx = obj.SelectedIndex; if isempty(idx) newidx = 1; else newidx = idx(1)+1; if newidx>length(obj.Items) newidx = 1; end end obj.SelectedIndex = double(newidx); end