www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@itemList/decrementSelection.m

    function decrementSelection(obj)
%DECREMENTSELECTION Move selection up the list
%
%  DECREMENTSELECTION(OBJ) moves the selection to the previous one in the
%  list as it is currently displayed on screen.  When the selection reaches
%  the beginning of the list it wraps to the end again.  If the selection
%  is initially empty, the top item is selected.  If there are multiple
%  items initially selected, the item before the first selection will
%  become selected.
%
%  Note that the selection is moved up 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<1
            newidx = length(obj.Items);
        end
    end
    obj.SelectedIndex = double(newidx);
end