matlab - Simulink: Add controls to simulink mask tab programatically -
i trying add parameter mask tab, using m-code. let's want add 'edit' parameter, , 'popup' parameter.
so far, cannot put them in tab, stay in general group. mathworks documentation failing provide working guidelines:
- the adddialogcontrol method failing else 'text' , 'hyperlink' items
- the 'tabname' parameter issue warning (going removed, not allowed use). warning says "use tab dialog controls add parameters tabs ". there's no documentation this, nowhere.
- the example provide incomplete , goes not give displayed result (parameters stay out of tab), see link: https://www.mathworks.com/help/simulink/ug/control-masks-programmatically.html#bu47973-4
i noticed there's simulink.dialog.control class have 'moveto' method, parameters not simulink.dialog.control, simulink.maskparameter instance. there simulink.dialog.parameter.control class not know objects belong nor if me.
thanks helping, need minimal example show me how this.
here way it: using 'moveto' method spoke above.
to access parameter simulink.dialog.parameter (which contains moveto method) simulink.maskparameter create, need use getdialogcontrol on maskparameter
convoluted , complex ? yes, that's have do.
here mwe:
block = 'untitled1/atomic subsystem'; wmask = simulink.mask.get(block); if ~isempty(wmask) wmask.delete(); end wmask = simulink.mask.create(block); wmask.adddialogcontrol('tabcontainer','tabcontainer'); wtabcontainer = wmask.getdialogcontrol('tabcontainer'); wtab1 = wtabcontainer.adddialogcontrol('tab', 'tab1'); wtab2 = wtabcontainer.adddialogcontrol('tab', 'tab2'); wtab1.prompt = 'programatically added tab1'; wtab2.prompt = 'programatically added tab2'; wtextonfirst = wtab1.adddialogcontrol('text', 'textonfirst'); wtextonfirst.prompt = 'some text on first tab'; wtextonsecond = wtab2.adddialogcontrol('text', 'textonsecond'); wtextonsecond.prompt = 'some text on first tab'; wfield = wmask.addparameter('name', 'textfield' ... , 'type', 'edit'... , 'prompt', 'programatically added text field'... , 'value', 'toto'... , 'evaluate', 'on'... , 'tunable', 'off'... , 'enabled', 'on'... , 'visible', 'on'... , 'callback', 'disp( get_param(gcb, ''textfield''))'); wpopup = wmask.addparameter('name', 'popupfield' ... , 'type', 'popup'... , 'prompt', 'programatically added popup field'... , 'typeoptions', {'value1', 'value2', 'value3'}... , 'evaluate', 'on'... , 'tunable', 'off'... , 'enabled', 'on'... , 'visible', 'on'... , 'callback', 'disp( get_param(gcb, ''popupfield''))'); wfielddialog = wmask.getdialogcontrol('textfield'); wpopupdialog = wmask.getdialogcontrol('popupfield'); wfielddialog.moveto(wtab1); wpopupdialog.moveto(wtab2);
Comments
Post a Comment