CustomDisplay functionality for AppDesigner apps

6 Ansichten (letzte 30 Tage)
Anthony
Anthony am 8 Jan. 2025
Kommentiert: Anthony am 23 Jan. 2025
I'm developing an AppDesigner App that I intend to interact with from the console. Right now, when I display my app at the console, my custom members get buried under all the public handles as shown below:
>> hApp
hApp =
MyApp with properties:
UIFigure: [1×1 Figure]
FileMenu: [1×1 Menu]
OpenMenu: [1×1 Menu]
SaveMenu: [1×1 Menu]
... % Many more handles omitted for brevity % ...
foo: 0
bar: [1x1 struct]
baz: [1x1 struct]
I'm trying to achieve something similar to this, where the least useful public members are hidden in the properties link:
>> hApp.UIFigure
ans =
Figure (MyApp) with properties:
Number: []
Name: 'MyApp'
Color: [940.0000e-003 940.0000e-003 940.0000e-003]
Position: [2.1360e+003 -663.0000e+000 640.0000e+000 480.0000e+000]
Units: 'pixels'
Show all properties
The Figure class can easily achieve this due to inheritance from matlab.mixin.CustomDisplay. However, AFAIK, it is not possible to edit the inheritance of AppDesigner apps.
How do I hide visibility of particular members without reinventing the wheel?

Antworten (2)

Pratyush Swain
Pratyush Swain am 13 Jan. 2025
Hi Anthony,
I do not think the AppDesigner framework allows editing the inheritance structure of apps. As a workaround, when you have too many public handles, consider grouping your custom properties into a struct.
Please refer to this following workflow:
1 - Define a property to contain the custom components
properties (Access = public)
myprops struct % Group all custom components here
end
2 - Define a function where you will group the components
The idea is you should add all your custom components here -
function initializeProps(app)
app.myprops = struct();
% Group custom components into a struct
app.myprops.baz = app.baz;
app.myprops.bar = app.bar;
app.myprops.foo = app.foo;
end
3 - Call the function
Add a callback function to the main app component (from the design view) - name it as appStartup(), call the grouping function inside this.
initializeProps(app);
Finally you can view the custom components like this:
I have also attached a sample mlapp file for your reference.
Let me know if this helps.
  1 Kommentar
Anthony
Anthony am 23 Jan. 2025
That's a bit clunky, but I see where you are going with this.
Unfortunately, I also want to do this with methods as well as members. Members were just convenient to illustrate the issue.
It seems a little awkward to encode handles into anonymous functions in order to call MyApp members from the console, but doable.
Thanks anyway!

Melden Sie sich an, um zu kommentieren.


Githin George
Githin George am 21 Jan. 2025
Another workaround I would suggest is to Export your App outside of App Designer and modify the inheritance rule. Multiple Inheritance seems to be working well for this use case and you can override the functions as you would for a Figure object.
  1 Kommentar
Anthony
Anthony am 23 Jan. 2025
I actually considered that option. However, AFAIK there is no way to import the code back into AppDesigner. At that point, you are constrained to a full programmatic workflow, which kind of defeats the purpose of AppDesigner.
Now if you can think of a better way to use mixins natively, please let me know.
Thanks!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Customize Object Display for Classes finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by