Why is event PreUpdate and PostUpdate not triggered in ChartContainer?

6 Ansichten (letzte 30 Tage)
Jacob-Jan Sloots
Jacob-Jan Sloots am 12 Dez. 2025 um 13:59
Hi all,
I’ve created a ChartContainer in MATLAB R2024b and need to track when its update routine finishes so I can restore an internal property to its original value. During setup, I added listeners for the PreUpdate and PostUpdate events of the ChartContainer.
However, when I change a property, the update method runs, but neither the PreUpdate nor PostUpdate events seem to fire.
Below I share the class implementation:
classdef TestComponent < matlab.graphics.chartcontainer.ChartContainer
%% Properties
properties (AbortSet)
% Internal use. Indicates update is required, triggered by external
% property.
TriggerUpdate (1,1) logical = false;
end %properties
properties (Transient, NonCopyable, Hidden, SetAccess = protected, UsedInUpdate = false)
% Event listener array
EventListeners (1,:) event.listener
end
%% Protected Methods
methods (Access = protected)
function setup(obj)
% Setup routine
% Show setup routine is executed
disp('setup')
% Setup listeners to all events in the class
metaClass = meta.class.fromName(class(obj));
eventList = {metaClass.EventList.Name};
listenAcces = {metaClass.EventList.ListenAccess};
% Initialize listener to post-update event
for idx = 1:numel(eventList)
if ~strcmpi(listenAcces{idx}, {'public', 'protected'})
continue
end
obj.EventListeners(end+1) = listener(obj, ...
eventList{idx}, @(s,e) obj.showEvent(e));
end
end %function
function update(obj)
% Update routine
% Show update routine is executed
disp('update')
end %function
end %methods
methods
function showEvent(obj, e)
disp(e)
end %function
end %methods
end
Does anyone know why these events aren’t triggered? For ComponentContainer, the events work as expected.

Antworten (0)

Kategorien

Mehr zu Developing Chart Classes finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by