I'd like to customize some of the MATLAB uicontrols (such as the drop-down box) to give them more user-friendly functionality.
My question is: Is it possible to extend/inherit the uicontrol? If so, how do you do it? If not, is there a workaround?
I have tried this basic code just to get it setup, but I receive the following error:
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
The error occurs when I try to add it to a figure:
cmb = ComboBox();
set(cmb, 'Parent', obj.ui_figure);
Edit: After thinking about it, I think this would be a decent workaround, however, I'd still like to know how to extend uicontrol if it's possible.
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