Avatar of a custom AppDesigner component created in Matlab
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
Robyn Jackey
2023-4-28
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?
采纳的回答
Robyn Jackey
2023-5-2
编辑:Robyn Jackey
2023-5-2
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 个评论
Robyn Jackey
2023-5-2
@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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Create Custom UI Components 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!