App Desinger: How to access Labels/Spinners via "Tags" in a custom UI component?
Ältere Kommentare anzeigen
I have a modularized App Designer app with several custom UI components. One UI component is a setting for units (e.g. km/h - mph or deg - radiant). These settings should be applied to all other custom UI components. To reduce the implementation work I wan't a generic solution like:
- User changed the setting from "rad" toi "deg"
- all custom UI components get notified and get the changed data
- in the components should be a function with updates all Labels tagged with "LabelUnitAngle" from "rad" to "deg"
The non-generic solution is already working: comp.WheelAngleunitLabel.Text=comp.appSettings.units.angle.text;
comp.WheelAngleSpinner.Value = comp.ParamStore.WheelAngle*comp.appSettings.units.angle.factor;
I tried findall and findobj and tried using metaclasses but still no luck.
2 Kommentare
dpb
am 27 Nov. 2025
It would undoubtedly help if you could post the startup code section that creates the components in question.
Can you find the app uifigure itself programmatically, first, just for starters?
Have you tried passing the UIFigure handle as the object tree starting point in findall(), etc., ...?
Walter
am 28 Nov. 2025
Antworten (1)
Mario Malic
am 29 Nov. 2025
Verschoben: Image Analyst
am 29 Nov. 2025
0 Stimmen
Just thinking out here, wouldn't you want an each component to have an internal method that changes values/labels/anything that relates to the selected unit?
Create an event in your main component and make it trigger when the unit is changed (user interaction). Subscribe your other components to it and fire up the internal event to change units.
4 Kommentare
Image Analyst
am 29 Nov. 2025
Excellent solution. 🤔
Mario Malic
am 29 Nov. 2025
thanks! 😊
Walter
am 1 Dez. 2025
Mario Malic
am 2 Dez. 2025
Bearbeitet: Mario Malic
am 2 Dez. 2025
i see what you mean. i think, that, if you add Tags to the UI component, you would need to give devs a clear instruction how to do it. For example, if you have an Edit Field and Label component that are paired up to display the physical quantity you want to show. Then you would tag them as Quantity_1 and Value_1, then you would do something similar for all components that you want to use to show the values. This is a quick solution, but it works. You can search components within the UIFigure by Tags property to find the components you have given tag to, check findall function.
I don't know how difficult this is since I haven't played with custom components, but, what if you actually add a extend the default UI components to account for units? For example, to add logic for units and values in the combo box that is mentioned above.
Kategorien
Mehr zu Develop Apps Programmatically finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!