widgets-toolbox icon indicating copy to clipboard operation
widgets-toolbox copied to clipboard

DatetimeSelector ValueChanged callback does not include PreviousValue

Open OhHey-ItsDave opened this issue 1 year ago • 1 comments

DatetimeSelector widget's protected methods: onDateEdited(), onTimeEdited(), and onTimeZoneChanged() do not include the previous value from the "evt" struct passed into them with the "evtOut" struct they then pass to the ValueChanged callback in App Designer.

Result is that the callback exposed within App Designer's Code View will always have "event.PreviousValue" equal "[ ]".

https://github.com/mathworks/widgets-toolbox/blob/4028f1911f357ab3fc1b70347c9e8929b23146ff/widgets/%2Bwt/DatetimeSelector.m#L316

OhHey-ItsDave avatar Apr 22 '24 21:04 OhHey-ItsDave

Issue can be corrected by recording widget's current Value at the top of these functions, before edits are made.

newValue = evt.Source.Value; % Already present previousValue = obj.Value; % Added previousValue variable

Then including the previousValue in evtOut

evtOut = wt.eventdata.ValueChangedData(obj.Value, previousValue); % Modified evtOut

OhHey-ItsDave avatar Apr 22 '24 21:04 OhHey-ItsDave