Hide class property, but retain autocomplete?

8 ビュー (過去 30 日間)
Philip Ohnewein
Philip Ohnewein 2018 年 11 月 15 日
コメント済み: Philip Ohnewein 2018 年 11 月 18 日
Hi all,
Following question:
I have a handle class, and I'd like to hide certain properties from being displayed in the command window when I type an object. To do this, I define the property as hidden:
classdef xy < handle
properties (Hidden)
abc
end
end
Now if do so, I lose autocomplete capability in the command window:
my_obj = xy();
xy.[TAB]
(autocomplete only works if abc has no Hidden attribute).
So, my question is: How can I can hide a property from display, but keep it autocompleting in the command window?
Thank you very much!
Philip

採用された回答

Guillaume
Guillaume 2018 年 11 月 17 日
Hidden means hidden, from display and autocompletion. There's no workaround.
However, what you could do is customise the display of your class, so that it only displays whatever you want even if the property is not hidden. For that you'd have to derive your class from matlab.mixin.CustomDisplay and override getPropertyGroups to omit the property you want to hide.
All in all, a lot of works for something that doesn't sound very logical.
  1 件のコメント
Philip Ohnewein
Philip Ohnewein 2018 年 11 月 18 日
Thanks for your reply!
I was not aware of matlab.mixin.CustomDisplay. Thank you for pointing me at that.
I know my question doesn't sound very logical at first view, but we have good reasons for this design in our application. Also the arbitrary reordering of properties makes a lot of sense, in our case.
The properties which are hidden but should support auto-completion are Dependent properties that make working with our main objects in the command window more straightforward. Apart from that, they are not important or characteristic properites for the object, so they basically just clutter the display, and leaving them out will reduce the number of properties by around 50%, while the other 50% are significant properties (for the user). Hope this gives some insight... :-)
@per isakson: Concerning private and protected properties: This behavior is more obvious to me, because private and protected is more concerned with the design of an application, whereas Hidden properties, well, not to the same extent, I would say. I am only talking about public, Hidden properties in my case.
So thank you both for your replies!
Philip

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by