Autocomplete of properties for hgsetget derived class

4 ビュー (過去 30 日間)
Oleg Komarov
Oleg Komarov 2014 年 6 月 28 日
コメント済み: James 2014 年 10 月 2 日
DESIRED BEHAVIOUR
If you create:
h = uicontrol('style','edit');
Then if you type
h.<tab>
and then select 'HorizontalAlignment', you can again < tab > to get a list of alignment options.
Alternatively, with
set(h, 'HorizontalAlignment', ' <tab> ...
ATTEMPT TO REPRODUCE IT
I am wondering if there is a way to take advantage of this behaviour for user defined classes of the type hgsetget
I tried
classdef foo < hgsetget
properties
HorizontalAlignment
end
end
Then in a separate folder, i.e. .\+foo\, I created and enumerator
classdef HorizontalAlignment
enumeration
left
center
right
end
end
but to no avail.
I tried several things, like defining a set.HorizontalAlignment(obj,val) mnethod which then calls the foo.HorizontalAlignment class, still no way to get the autocomplete.
Anybody has hints?

採用された回答

Oleg Komarov
Oleg Komarov 2014 年 7 月 9 日
編集済み: Oleg Komarov 2014 年 7 月 9 日
I've been fiddling around and by mistake I found that the matlab.system.StringSet class of the matlab.System package allows exactly the < TAB > complete behaviour.
Note : the doc links are under symulink, however the package is under:
fullfile(matlabroot, 'toolbox\matlab\system')
and therefore, does not require Symulink to be installed.
A barebone example :
classdef foo < matlab.System
properties
Coordinates
end
properties(Hidden,Transient)
CoordinatesSet = matlab.system.StringSet({'north','south','east','west'});
end
end
usage :
obj = foo
obj =
System: foo
Properties:
Coordinates: []
set(obj,'Coordinates','<TAB>
.
  2 件のコメント
Yair Altman
Yair Altman 2014 年 8 月 12 日
Nice one, Oleg.
I added your discovery to my recent post on class property tab-completion .
James
James 2014 年 10 月 2 日
Note that this only works for classes derived from matlab.System.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreate System Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by