Avatar of a custom AppDesigner component created in Matlab
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Eric Delgado
el 28 de Abr. de 2023
Comentada: Robyn Jackey
el 2 de Mayo de 2023
I created a custom AppDesigner component, but when I open an app with it, Matlab shows this warning:
Warning: Unable to capture UI component avatar. Users will be unable to see the component preview when dragging the UI
component from the Component Library onto the canvas.
> In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
I guess the avatar is like a preview of the object - such as the big "<HTML>" for an uihtml -, right? Is it already possible to create this avatar?
3 comentarios
Robyn Jackey
el 28 de Abr. de 2023
Something in the component may be erroring out, possibly only when used in app designer. I assume the metadata generation worked ok? What happens when you drag it into a new app from the component browser?
Respuesta aceptada
Robyn Jackey
el 2 de Mayo de 2023
Editada: Robyn Jackey
el 2 de Mayo de 2023
Normally the avatar should get auto-generated (via getframe) when you configure the appdesigner metadata, however in your case it likely failed. As a workaround, you can screenshot your component in .png format and place it in the \resources folder next to appdesigner.json, where you would specify “./nameOfAvatarImage.png” as the value for the “avatar” field.
There are limited property editors currently available for custom components in app designer, and unfortunately color and font are not currently in that list:
For now you should be able to use validatecolor in your component's BackgroundColor property definition to guard against incorrect entries.
I have requested improvemnts for this. Are there any other common editors you need besides font and color properties?
2 comentarios
Robyn Jackey
el 2 de Mayo de 2023
@Eric Delgado, I agree this can start to get challenging with a more complex component.
Perhaps it's possible to make just one private property that lists any changes in a string array? Add set methods for each relevant property and inside of that add the property to the list. In your update method, check for any matches of the relevant property in the list, then clear it after making the update.
Another approach I've taken is to have a private property be a true/false flag that gets toggled true inside specific set methods. For example, I had a custom component that wrapped a chartcontainer with MxN plots inside. If I changed M or N, the set method would turn a flag true that the update would know to delete and recreate the plots rather than doing a simpler update, then return the flag to false state.
Más respuestas (0)
Ver también
Categorías
Más información sobre Create Custom UI Components en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!