3737 % Indicates whether to allow sort controls %RAJ - Future feature
3838 % Sortable (1,1) matlab.lang.OnOffSwitchState = true
3939
40+ % Inidicates what to do when add button is pressed (select from
41+ % Items or custom using ButtonPushed event or ButtonPushedFcn)
42+ AddSource (1 ,1 ) wt.enum.ListAddSource = wt.enum.ListAddSource.Items
43+
4044 end % properties
4145
4246
@@ -152,9 +156,20 @@ function update(obj)
152156 obj.ListBox.Items = obj .Items(selIdx );
153157 obj.ListBox.ItemsData = selIdx ;
154158
159+ % Update button enable states
160+ obj .updateEnables();
161+
162+ end % function
163+
164+
165+ function updateEnables(obj )
166+
155167 % Button enables
156168 if obj .Enable
157169
170+ % What is selected?
171+ selIdx = obj .SelectedIndex ;
172+
158173 % Highlighted selection in list?
159174 hiliteIdx = obj .getListBoxSelectedIndex();
160175
@@ -196,8 +211,8 @@ function onSelectionChanged(obj,evt)
196211 newValue = itemsData(evt .Value );
197212 end
198213
199- % Force update
200- obj .update ();
214+ % Update button enable states
215+ obj .updateEnables ();
201216
202217 % Trigger event
203218 evtOut = wt .eventdata .ValueChangedData(newValue , oldValue );
@@ -212,7 +227,16 @@ function onButtonPushed(obj,evt)
212227 switch evt .Tag
213228
214229 case ' Add'
215- obj .promptToAddListItems()
230+
231+ switch obj .AddSource
232+
233+ case wt .enum .ListAddSource .Items
234+ obj .promptToAddListItems()
235+
236+ case wt .enum .ListAddSource .Custom
237+ notify(obj ," ButtonPushed" ,evt );
238+
239+ end % switch obj.AddSource
216240
217241 case ' Remove'
218242 obj .removeListBoxSelection();
0 commit comments