我想定制一些MATLAB的uicontrols(如下拉框),给他们更多的用户友好的功能。扩展MATLAB uicontrol
我的问题是:是否可以扩展/继承uicontrol?如果是这样,你怎么做?如果没有,是否有解决方法?
我曾尝试这种基本的代码只是为了得到它的设置,但我收到以下错误:
:The specified super-class 'uicontrol' contains a parse error or cannot be found on MATLAB's search path, possibly shadowed by another file with the same name.
classdef ComboBox < uicontrol
methods(Access = public)
function obj = ComboBox()
set(obj, 'Style', 'popup');
end
end
end
当我尝试将其添加到一个数字出现的错误
cmb = ComboBox();
set(cmb, 'Parent', obj.ui_figure);
编辑:考虑这件事之后,我认为这将是一个不错的解决办法,豪如果可能的话,我仍然想知道如何扩展uicontrol。
classdef ComboBox < uicontrol
properties(Access = public)
Control;
end
methods(Access = public)
function obj = ComboBox(parent, items)
obj.Control = uicontrol();
set(obj.Control, 'Style', 'popup');
set(obj.Control, 'Parent', parent);
set(obj.Control, 'String', items);
end
end
end