File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ function setup(testCase)
3939
4040 % Set the initial items
4141 testCase .verifySetProperty(" Items" , testCase .ItemNames );
42+
43+ % Set callback
44+ testCase.Widget.ButtonPushedFcn = @(s ,e )onCallbackTriggered(testCase ,e );
45+ testCase.Widget.ValueChangedFcn = @(s ,e )onCallbackTriggered(testCase ,e );
46+ testCase.Widget.HighlightedValueChangedFcn = @(s ,e )onCallbackTriggered(testCase ,e );
4247
4348 end % function
4449
@@ -363,6 +368,29 @@ function testUserButtons(testCase)
363368 testCase .verifyNumElements(b , 2 );
364369 testCase .press(b(1 ))
365370 testCase .press(b(2 ))
371+
372+ % Verify callbacks fired
373+ testCase .verifyEqual(testCase .CallbackCount , 2 );
374+
375+ end % function
376+
377+
378+
379+ function testAddSource(testCase )
380+
381+ % Get the widget
382+ w = testCase .Widget ;
383+ buttonGrid = testCase .Widget .ListButtons ;
384+ button = buttonGrid .Button ;
385+
386+ % Add User buttons
387+ w.AddSource = ' ButtonPushedFcn' ;
388+
389+ % Press the buttons
390+ testCase .press(button(1 ))
391+
392+ % Verify callbacks fired
393+ testCase .verifyEqual(testCase .CallbackCount , 1 );
366394
367395 end % function
368396
Original file line number Diff line number Diff line change @@ -411,7 +411,9 @@ function onButtonPushed(obj,evt)
411411 obj .promptToAddListItems()
412412
413413 case wt .enum .ListAddSource .ButtonPushedFcn
414- notify(obj ," ButtonPushed" ,evt );
414+ % Trigger event for user buttons
415+ evtOut = wt .eventdata .ButtonPushedData(evt .Button );
416+ notify(obj ," ButtonPushed" ,evtOut );
415417
416418 end % switch obj.AddSource
417419
@@ -426,7 +428,8 @@ function onButtonPushed(obj,evt)
426428
427429 otherwise
428430 % Trigger event for user buttons
429- notify(obj ," ButtonPushed" ,evt );
431+ evtOut = wt .eventdata .ButtonPushedData(evt .Button );
432+ notify(obj ," ButtonPushed" ,evtOut );
430433
431434 end % switch
432435
You can’t perform that action at this time.
0 commit comments