Skip to content

Commit f7c0d47

Browse files
committed
ListSelector cleanup
1 parent 78fcb3b commit f7c0d47

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

widgets/+wt/ListSelector.m

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,20 @@
4848
% Get original items and highlight
4949
oldValue = obj.Value; %#ok<MCSUP>
5050
oldHighlight = obj.HighlightedValue; %#ok<MCSUP>
51-
52-
% What's currently selected?
53-
oldLBHighlight = obj.getListBoxSelectedIndex();
5451

5552
% Retain the matching original value selection
5653
isPresent = ismember(oldValue, newItems);
5754
newValue = oldValue(isPresent);
5855

59-
% Retain the matching original highlight indices
60-
isPresentIdx = find(isPresent);
61-
newHighlightIdx = intersect(oldLBHighlight, isPresentIdx, 'stable');
62-
63-
% In case items were removed, we can back up to the highlight
64-
% values
56+
% Attempt to retain the highlight values
6557
isPresent = ismember(oldHighlight, newItems);
6658
newHighlight = oldHighlight(isPresent);
6759

6860
% Set new items
6961
obj.Items = newItems;
70-
% newValue = intersect(oldValue, value, 'stable')
7162

72-
% Set selection and highlight for consistency
73-
% newHighlight = intersect(oldHighlightValue, value, 'stable')
63+
% Set selection for consistency
7464
obj.Value = newValue; %#ok<MCSUP>
75-
% obj.HighlightedValue = newHighlight; %#ok<MCSUP>
7665

7766
% Set highlight for consistency
7867
if obj.AllowDuplicates %#ok<MCSUP>
@@ -84,18 +73,6 @@
8473
obj.HighlightedValue = newHighlight; %#ok<MCSUP>
8574
end
8675

87-
% elseif isempty(newHighlightIdx)
88-
%
89-
% % Set empty selection
90-
% obj.ListBox.ValueIndex = []; %#ok<MCSUP>
91-
%
92-
% else
93-
%
94-
% % Keep the same indices selected
95-
% obj.ListBox.ValueIndex = newHighlightIdx; %#ok<MCSUP>
96-
%
97-
% end
98-
9976
end
10077

10178

0 commit comments

Comments
 (0)