Matlab - app designer - component name and callback

Hi,
In App Designer
How can we know the name of a modified component when his callback is also connected to other component ?
Thks

2 comentarios

Adam Danz
Adam Danz el 21 de Ag. de 2019
Are you asking how to idenitify which component invoked a callback function in the case where multiple components are assigned the same callback function?
patrick bouche
patrick bouche el 21 de Ag. de 2019
Yes!

Iniciar sesión para comentar.

Respuestas (1)

Adam Danz
Adam Danz el 21 de Ag. de 2019
Editada: Adam Danz el 22 de Ag. de 2019
The 2nd input to a callback function in App Designer is "event'. event.Source is the handle to the object that invoked the callback function. event.EventName is the name of the event (a string).
objHandle = event.Source;
objName = event.EventName;

4 comentarios

patrick bouche
patrick bouche el 22 de Ag. de 2019
I am sorry but it doesn't work
event.EventName give 'ValueChanged'
Guillaume
Guillaume el 22 de Ag. de 2019
Yes, EventName is the name of the event, and it's useful if the same callback is used to catch different types of events. It has nothing to do with what object triggered the callback,
However, as Adam said, the Source property is the handle to the object that triggered the callback so that's what you should use.
Objects don't really have names. However, you can assign most (all?) objects a name by assigning a string to their Tag property. Then you can identify the object by its tag like this
objHandle = event.Source;
objHandle.Tag
If you haven't assigned a Tag, the tag property will be empty.
René Lampert
René Lampert el 27 de En. de 2022
Hy Guillaume,
could you please explain in detail what you mean with " it's useful if the same callback is used to catch different types of events. " I dont get the point out of this phrase. Do you have a minimal example fot this?

Iniciar sesión para comentar.

Categorías

Más información sobre Develop Apps Programmatically en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Ag. de 2019

Comentada:

el 27 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by