private properties for UI component in app designer

조회 수: 14 (최근 30일)
Aleksandr Petrusev
Aleksandr Petrusev 2023년 7월 6일
댓글: Aleksandr Petrusev 2023년 7월 7일
Hello everyone,
I am wondering if it is possible to access the private properties of the UI component in the external function. In my example, I have an EV_lite component and inside of it I use a “DropDownValueChanged” callback which executes a function outside the component:
However, this function gives us an error, because it requires a private property “CategoryEVDropDown”:
I have dozens of such properties. Could you advise how to declare these private properties as public or access them directly outside of the component?
Or the only option is to put all the code inside of the component?
Thank you in advance!

답변 (1개)

Sandeep Mishra
Sandeep Mishra 2023년 7월 6일
Hello Aleksandr,
I understand that you are trying to create a private property of the UI component, but you cannot access that function outside the component.
In MATLAB App Designer, you can create public UI components in the following ways
  1. In Design view, Drag and Drop the UI component will make public UI component by default
  2. In Code view, You can create new Public Property by selecting Public Property from Property option.
  3. In Code view, You can change the "Access" modifier of properties from private to public like below
properties (Access = public)
CategoryEVDropDown
end
You can refer to the below documentation to learn more about MATLAB App Designer properties.
  댓글 수: 6
Sandeep Mishra
Sandeep Mishra 2023년 7월 7일
Also from you function, It seems like you need the "DropDown" value instead of whole component
So it is recommended to pass "DropDown" value from the component to the function, instead of whole Component.
Aleksandr Petrusev
Aleksandr Petrusev 2023년 7월 7일
Thank you. This approach works fine to get the value of the property. However, chaging DropDownPublicProperty doesn't impact initial DropDown. In the end, I found "dependent property" which allows both getting value of private property and change it:
https://www.mathworks.com/help/matlab/matlab_oop/access-methods-for-dependent-properties.html
I hope it will help others

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by