Editing component tag in App Designer

I cannot find a way to edit component (Button, CheckBox, DropDown, etc.) tags in App Designer. Tag is not a property accessible through the component browser. Am I missing something?

Answers (4)

Jeff Baker
Jeff Baker on 2 Jun 2020
A good use for the tag property is if many buttons will share the same callback. The callback can use the event.Source.Tag property to figure out which button was pressed.
Adam
Adam on 21 Feb 2019
Edited: Adam on 21 Feb 2019
You should have a 'Component Browser' (mine is top right of the screen with default layout) with your components in a tree under the figure. You can double click on the name after app. and edit it.
stuff.png

11 Comments

Thank you for your response. Perhaps I wasn't clear. I don't want to edit the name of the component. I want to edit the Tag property of the component. Buttons, CheckBoxes, and many other components have a Tag property that can be set. Unlike most - or all of the other properties - the tag property cannot be set in the component properties windows that shows up below the component browser.
Adam
Adam on 25 Feb 2019
Edited: Adam on 25 Feb 2019
How is the tag different to the name? In an appdesigner application I wouldn't think Tag to be of any use since all components are easily referable to via the property name (which I had assumed was the same as the tag anyway).
I just tried changing 'Tag' programmatically though and that worked fine.
Tag is different than name in that multiple components can have the same Tag but different names. I am using Tag to group multiple UI components together so that I can change the properties (visible, enable) of all of the components in a group easily. That is at least one use of the tag property. Yes you can change Tag programmatically just as you can change any property programmatically. Why is the Tag property not accessible through the component browser. I would rather not have to clutter up a startup function or have to write a special function to set the Tag property of dozens of UI components.
You can put grouped components into an array stored as a property, though this also needs to be done in code. I'm surprised you can use the same tag for multiple components though, it didn't used to be possible for GUIDE components, for obvious reasons.
Imagine a scenario where you have multiple slides that perform similar tasks, and thus can share the same callback. In this callback, assigning each a tag value is an easy way to identify each slider, instead of giving each a callback of its own. Your suggestion of using a property to group the tags is a possible solution, but simply reading off a tag value is easier and I think more elegant than seeking out the source's position in a array.
The source of a callback should always be available in the callback though and the app also, meaning that the sliders could be referred to by their property nameon the app in that scenario I would have thought.
Ned
Ned on 21 Sep 2019
Edited: Ned on 22 Sep 2019
ok I'll give a more specific example. In my UI, I have some edit fields and sliders that are generated automatically. If a user changes the value of an edit field, the callback changes the value of the slider, and vice versa. In order to do this, I have the tags for each component set to a numeric value that's evaluated to get the correct index.
Do you have an easier/more elegant solution to do this for MULTIPLE sets of slides+buttons without using a tag?
I assume if the edit boxes and sliders are generated automatically you mean they are added programmatically after you have launched the GUI rather than in the Design View?
In which case you have to create their callbacks manually also? So then you could pass the relevent slider/edit box handle to the callback of the other one when you set it up, for each pair of slider, edit box.
Please, Adam, do you have an answer to the very simple question: "How can the property "Tag" be given a value in the appdesigner?" If it is not possible, then don't be afraid to admit that!
I have the exact same need myself. For now I have to write this manually somewhere in the code: e.g. "app.SwitchLocTab.Tag = 'LocPar';", which is just stupid. As Eric wrote: " I would rather not have to clutter up a startup function or have to write a special function to set the Tag property of dozens of UI components."
You ask yourself: "How is the tag different to the name?" - if you don't know that please let another person answer the question!
I'm not stopping anyone else from answering the question!
I see no valid purpose for 'tag' when using app designer. The purposes for which it had a use in GUIDE are no longer valid in my opinion (and apparently in the opinion of those who created app designer), so that was the basis of my answer and attempting to understand why someone would need to use the 'tag'.
Other people are free to give different answers and are also free to completely ignore my answer.
I think control of the tag would be very nice to have. I'm trying to create save and load state functions for my tool and if I could cross reference the components by unique tag names, that would help. Currently, I have to look at where the component is in the gui hierarchy AND cross reference a neighboring label in some cases to uniquely identify a component. I don't care to have my save function depend on the gui hierarchy because I might move a component. Ideally, the tag reflects the component name specified by the author.
Is there anyway to reference the component name programmatically? That would be the best solution for me. I don't see it in the property list.

Sign in to comment.

Dan
Dan on 20 Jan 2020
Edited: Dan on 20 Jan 2020
Nothing like writing a response and figuring it out a few minutes later ...
Apps have public properties for each gui item that can be referenced generically as a list using the metaclass function. Therefore, no need for tags.
Short answer: Use public properties to reference the GUI items instead of tags ... tags provide no added value that I can see other than the need to tag things dynamically (which could be done of course).
Ajay Pattassery
Ajay Pattassery on 28 Apr 2020
Edited: Ajay Pattassery on 28 Apr 2020
You can edit tag property of a component by locating the component in the component browser and then search for the property tag in the property inspector.
Refer the attached image.

2 Comments

New feature as of 2019b or 2020a release? Was not there in 2019a ...
You can search in the component browser for Tag property from R2020a. But in R2019a you can use the Tag property programmatically.

Sign in to comment.

Categories

Products

Release

R2018b

Asked:

on 21 Feb 2019

Answered:

on 2 Jun 2020

Community Treasure Hunt

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

Start Hunting!