Callbacks and event.EventData (specifically timer)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
From my understanding when writing callback functions, the function needs a signature like: callbackfcn(src, evt), where src is the handle to the object that initiated the callback and evt is the associated "event data".
When a uicontrol initiates my callback function, evt is of the class event.EventData, but when a timer initiates my callback function, evt is of the class struct. Although the fields of the struct are such that it makes the two cases similar, I was surprised by the difference.
Can someone help me understand why sometimes the event data is a struct and other times event.EventData.
0 commentaires
Réponses (1)
Taylor
le 17 Juil 2025
When UI controls were incorporated into the modern event system, they adopted the event.EventData class-based model. Timers, implemented before this, retained a simpler struct-based approach.
event.EventData allows subclassing, so for advanced or custom behavior (as with custom UI components), you can pass more detailed information by creating subclasses.
Both systems provide comparable information, but object-oriented event data is more robust and extensible for complex GUI interactions. Timer event data as a struct is sufficient for timer-related callbacks but less flexible for extension or integration with the rest of MATLAB's event model
0 commentaires
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!